static bool Prefix_TryCreateDialogForVersionMismatchWarnings(ref bool __result, Action confirmedAction) { SimpleLog.Log("Checking mod mismatch"); bool isModListSame = ScribeMetaHeaderUtility.LoadedModsMatchesActiveMods(out _, out _); bool useVersionCompare = ModMismatchFormatter.useVersionCompare; if (isModListSame) { SimpleLog.Log("ModList are same"); if (useVersionCompare) { SimpleLog.Log("use version checking"); bool isVersionSame = MetaHeaderUtility.isVersionSame(ModContentPackExtension.GetModsFromSave(useVersionCompare), ModContentPackExtension.GetModsFromActive(useVersionCompare)); if (!isVersionSame) { SimpleLog.Log("Version is different..."); string warningMessage = "Checking mismatch for mod and mod versions... please wait"; Messages.Message(warningMessage, MessageTypeDefOf.SilentInput, false); CreateModMismatchWindow(confirmedAction, useVersionCompare); __result = true; return(false); } } __result = false; return(true); } else { SimpleLog.Log("Mod mismatch!"); CreateModMismatchWindow(confirmedAction, useVersionCompare); __result = true; return(false); } }
public void LoadWorld() { this.ReferenceTable.ClearReferences(); if (ScribeMultiLoader.Empty()) { PreloadWorldColoniesMaps(); } Status = PersistentWorldLoadStatus.Loading; this.SetCurrentFile(worldFilePath); Log.Message("Loading world " + worldFolderPath); // Select world to load XML node data for. ScribeMultiLoader.SetScribeCurXmlParentByFilePath(this.worldFilePath); // Required otherwise errors because of internal requirements. ScribeMetaHeaderUtility.LoadGameDataHeader(ScribeMetaHeaderUtility.ScribeHeaderMode.Map, true); // Load data. Scribe_Deep.Look <PersistentWorldData>(ref this.persistentWorld.WorldData, "data"); //this.persistentWorld.ResetPlayerFaction(FactionDefOf.PlayerColony); Log.Message("Loaded world data..."); }
private void DoExport(string name) { try { try { Scribe.InitWriting(FilePath(name), "ManagerJobs"); } catch (Exception ex) { GenUI.ErrorDialog("ProblemSavingFile".Translate(ex.ToString())); throw; } ScribeMetaHeaderUtility.WriteMetaHeader(); _jobStackIO = Manager.For(manager).JobStack; Scribe_Deep.LookDeep(ref _jobStackIO, "JobStack"); } catch (Exception ex2) { Log.Error("Exception while saving jobstack: " + ex2); } finally { Scribe.FinalizeWriting(); Messages.Message("FM.JobsExported".Translate(_jobStackIO.FullStack().Count), MessageSound.Standard); Refresh(); } }
public static void SaveToXML(Blueprint blueprint) { try { try { Scribe.InitWriting(FullSaveLocation(blueprint.name), "Blueprint"); } catch (Exception ex) { GenUI.ErrorDialog("ProblemSavingFile".Translate(ex.ToString())); throw; } ScribeMetaHeaderUtility.WriteMetaHeader(); Scribe_Deep.LookDeep(ref blueprint, "Blueprint"); } catch (Exception ex2) { Log.Error("Exception while saving blueprint: " + ex2); } finally { Scribe.FinalizeWriting(); } // set exported flag. blueprint.exported = true; }
public static PathDataLog LoadFromFile(string filename) { var pathData = new PathDataLog(); try { Scribe.InitLoading(filename); ScribeMetaHeaderUtility.LoadGameDataHeader(ScribeMetaHeaderUtility.ScribeHeaderMode.Map, false); Scribe.EnterNode("PathData"); pathData.ExposeData(); Scribe.ExitNode(); } catch (Exception e) { Log.Error("Exception while loading: " + e); } finally { // done loading Scribe.FinalizeLoading(); Scribe.mode = LoadSaveMode.Inactive; } return(pathData); }
private static void Read(string filepath) { Scribe.loader.InitLoadingMetaHeaderOnly(filepath); ScribeMetaHeaderUtility.LoadGameDataHeader(ScribeMetaHeaderUtility.ScribeHeaderMode.Map, false); importList = ScribeMetaHeaderUtility.loadedModIdsList; Scribe.loader.FinalizeLoading(); }
public static bool PreFLoadGameFromSaveFile(string fileName) { string str = GenText.ToCommaList(from mod in LoadedModManager.RunningMods select mod.ToString(), true); Log.Message("Loading game from file " + fileName + " with mods " + str); DeepProfiler.Start("Loading game from file " + fileName); Current.Game = new Game(); DeepProfiler.Start("InitLoading (read file)"); Scribe.loader.InitLoading(GenFilePaths.FilePathForSavedGame(fileName)); DeepProfiler.End(); ScribeMetaHeaderUtility.LoadGameDataHeader(ScribeMetaHeaderUtility.ScribeHeaderMode.Map, true); bool flag = !Scribe.EnterNode("Κgame"); bool result; if (flag) { Log.Error("Could not find DTMG XML node."); Scribe.ForceStop(); GenScene.GoToMainMenu(); Messages.Message("Game MUST be created with 'Don't Tempt Me!' loaded. Please select a 'Don't Tempt Me!' save game file.", MessageTypeDefOf.RejectInput); result = false; } else { Current.Game = new Game(); Current.Game.LoadGame(); PermadeathModeUtility.CheckUpdatePermadeathModeUniqueNameOnGameLoad(fileName); DeepProfiler.End(); result = false; } return(result); }
public static XmlDocument SaveGame() { SaveCompression.doSaveCompression = true; ScribeUtil.StartWritingToDoc(); Scribe.EnterNode("savegame"); ScribeMetaHeaderUtility.WriteMetaHeader(); Scribe.EnterNode("game"); int currentMapIndex = Current.Game.currentMapIndex; Scribe_Values.Look(ref currentMapIndex, "currentMapIndex", -1); Current.Game.ExposeSmallComponents(); World world = Current.Game.World; Scribe_Deep.Look(ref world, "world"); List <Map> maps = Find.Maps; Scribe_Collections.Look(ref maps, "maps", LookMode.Deep); Find.CameraDriver.Expose(); Scribe.ExitNode(); SaveCompression.doSaveCompression = false; return(ScribeUtil.FinishWritingToDoc()); }
/// <summary> /// Read a save file /// </summary> /// <param name="filepath">The path to the savefile</param> private static void Read(string filepath) { Main.LogDebug("reading {0}", filepath); Scribe.SaveState(); Scribe.InitLoadingMetaHeaderOnly(filepath); ScribeMetaHeaderUtility.LoadGameDataHeader(ScribeMetaHeaderUtility.ScribeHeaderMode.Map, false); importList = ScribeMetaHeaderUtility.loadedModIdsList; Scribe.FinalizeLoading(); Scribe.RestoreState(); }
private void DoImport(SaveFileInfo file) { try { // load stuff Scribe.InitLoading(_folder + "/" + file.FileInfo.Name); Manager.LoadSaveMode = Manager.Modes.ImportExport; ScribeMetaHeaderUtility.LoadGameDataHeader(ScribeMetaHeaderUtility.ScribeHeaderMode.Map, false); Scribe.EnterNode("JobStack"); _jobStackIO.ExposeData(); Scribe.ExitNode(); Scribe.FinalizeLoading(); // resolve crossreferences // these are registered during the loading stage, and cleared afterwards // will most definitely give errors/warnings on crossgame imports CrossRefResolver.ResolveAllCrossReferences(); // replace the old jobstack Manager.For(manager).NewJobStack(_jobStackIO); // remove invalid jobs var invalid = 0; foreach (ManagerJob job in Manager.For(manager).JobStack.FullStack()) { if (!job.IsValid) { invalid++; job.Delete(false); } } // provide some feedback on failed import(s) // if debug is enabled the screen will also pop up with reference errors. if (invalid > 0) { Messages.Message("FM.InvalidJobsDeleted".Translate(invalid), MessageSound.SeriousAlert); } } catch (Exception e) { Log.Error("Exception while loading jobstack: " + e); } finally { // done? Scribe.mode = LoadSaveMode.Inactive; Manager.LoadSaveMode = Manager.Modes.Normal; Messages.Message("FM.JobsImported".Translate(_jobStackIO.FullStack().Count), MessageSound.Standard); Refresh(); } }
private static void SaveGame(string savePath) { LongEventHandler.QueueLongEvent(() => { string path = savePath + ".rws"; SafeSaver.Save(path, "savegame", delegate { ScribeMetaHeaderUtility.WriteMetaHeader(); Game game = Current.Game; Scribe_Deep.LookDeep(ref game, "game"); }); }, "Saving Path Data", false, null); }
private static void SaveCurrentGame() { try { string path = FilePathForTmpSave(); SafeSaver.Save(path, "savegame", delegate { ScribeMetaHeaderUtility.WriteMetaHeader(); Game target = Current.Game; Scribe_Deep.Look(ref target, "game"); }); } catch (Exception arg) { Log.Error("Exception while saving tmp game: " + arg); } }
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); }
static bool Prefix() { if (gameToLoad == null) { return(true); } SaveCompression.doSaveCompression = true; try { ScribeUtil.StartLoading(gameToLoad.SaveData); ScribeMetaHeaderUtility.LoadGameDataHeader(ScribeMetaHeaderUtility.ScribeHeaderMode.Map, false); Scribe.EnterNode("game"); Current.Game = new Game(); Current.Game.LoadGame(); // calls Scribe.loader.FinalizeLoading() SemiPersistent.ReadSemiPersistent(gameToLoad.SemiPersistent); } finally { SaveCompression.doSaveCompression = false; gameToLoad = null; } Log.Message("Game loaded"); if (Multiplayer.Client != null) { LongEventHandler.ExecuteWhenFinished(() => { // Inits all caches foreach (ITickable tickable in TickPatch.AllTickables.Where(t => !(t is ConstantTicker))) { tickable.Tick(); } if (!Current.Game.Maps.Any()) { MemoryUtility.UnloadUnusedUnityAssets(); Find.World.renderer.RegenerateAllLayersNow(); } }); } return(false); }
private static void CheckGameVersionAndMods(SaveFile file, Action action) { ScribeMetaHeaderUtility.lastMode = ScribeMetaHeaderUtility.ScribeHeaderMode.Map; ScribeMetaHeaderUtility.loadedGameVersion = file.rwVersion; ScribeMetaHeaderUtility.loadedModIdsList = file.modIds.ToList(); ScribeMetaHeaderUtility.loadedModNamesList = file.modNames.ToList(); if (!ScribeMetaHeaderUtility.TryCreateDialogsForVersionMismatchWarnings(action)) { action(); } else { Find.WindowStack.Windows .OfType <Dialog_MessageBox>() .Where(w => w.buttonAText == "LoadAnyway".Translate()) .Do(w => w.buttonAText = "Continue anyway"); } }
public static bool PreFSaveGame(string fileName) { try { Traverse traverse = Traverse.CreateWithType("GameDataSaveLoader").Field("lastSaveTick"); SafeSaver.Save(GenFilePaths.FilePathForSavedGame(fileName), "savegame", delegate { ScribeMetaHeaderUtility.WriteMetaHeader(); Game game = Current.Game; Scribe_Deep.Look <Game>(ref game, "Κgame", new object[0]); }); traverse.SetValue(Find.TickManager.TicksGame); } catch (Exception e) { Log.Message(string.Format("EXCEPTION! {0}.{1} \n\tMESSAGE: {2} \n\tException occurred calling {3} method", e.TargetSite.ReflectedType.Name, e.TargetSite.Name, e.Message)); } return(false); }
public void SaveWorldData(bool check = false) { Log.Message("Saving world data..."); this.persistentWorld.WorldData = PersistentWorldData.Convert(Current.Game, this.persistentWorld.WorldData); this.SetCurrentFile(new FileInfo(worldFilePath)); SafeSaver.Save(this.worldFilePath, "worldfile", delegate { ScribeMetaHeaderUtility.WriteMetaHeader(); Scribe_Deep.Look(ref this.persistentWorld.WorldData, "data"); }); if (check) { // ScribeSaver.FinalizeSaving() stops this from calling when Persistent World is present. Scribe.saver.loadIDsErrorsChecker.CheckForErrorsAndClear(); } Log.Message("Saved world data."); }
private void ReloadFiles() { selectedFile = null; spSaves.Clear(); mpReplays.Clear(); foreach (FileInfo file in GenFilePaths.AllSavedGameFiles) { spSaves.Add( new SaveFile(Path.GetFileNameWithoutExtension(file.Name), false, file) { rwVersion = ScribeMetaHeaderUtility.GameVersionOf(file) } ); } var replaysDir = new DirectoryInfo(GenFilePaths.FolderUnderSaveData("MpReplays")); if (!replaysDir.Exists) { replaysDir.Create(); } foreach (var file in replaysDir.GetFiles("*.zip").OrderByDescending(f => f.LastWriteTime)) { var replay = Replay.ForLoading(file); replay.LoadInfo(); mpReplays.Add( new SaveFile(Path.GetFileNameWithoutExtension(file.Name), true, file) { gameName = replay.info.name, protocol = replay.info.protocol } ); } }
internal static Blueprint LoadFromXML(SaveFileInfo file) { // set up empty blueprint Blueprint blueprint = new Blueprint(); #if DEBUG Log.Message("Attempting to load from: " + file.FileInfo.FullName); #endif // load stuff try { Scribe.InitLoading(BlueprintSaveLocation + "/" + file.FileInfo.Name); ScribeMetaHeaderUtility.LoadGameDataHeader(ScribeMetaHeaderUtility.ScribeHeaderMode.Map, true); Scribe.EnterNode("Blueprint"); blueprint.ExposeData(); Scribe.ExitNode(); } catch (Exception e) { Log.Error("Exception while loading blueprint: " + e); } finally { // done loading Scribe.FinalizeLoading(); Scribe.mode = LoadSaveMode.Inactive; } // if a def used in the blueprint doesn't exist, exposeData will throw an error, // which is fine. in addition, it'll set the field to null - which may result in problems down the road. // Make sure each item in the blueprint has a def set, if not - remove it. // This check itself will throw another error, which is also fine. User will have to resolve the issue manually. blueprint.contents = blueprint.contents.Where(item => item.BuildableDef != null).ToList(); // return blueprint. return(blueprint); }
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(); }
public static bool SaveShipAndRemoveItemStacks() { if (ShipInteriorMod.saveShip) { string str1 = Path.Combine(GenFilePaths.SaveDataFolderPath, "Ships"); DirectoryInfo directoryInfo = new DirectoryInfo(str1); if (!directoryInfo.Exists) { directoryInfo.Create(); } string name = Faction.OfPlayer.Name; var def = ShipInteriorMod.shipRoot.Map.GetSpaceAtmosphereMapComponent().DefinitionAt(ShipInteriorMod.shipRoot.Position); string str2 = Path.Combine(str1, name + "-" + def.Name + ".rwship2"); SafeSaver.Save(str2, "RWShip", (Action)(() => { ScribeMetaHeaderUtility.WriteMetaHeader(); Scribe_Values.Look <FactionDef>(ref Faction.OfPlayer.def, "playerFactionDef", null, false); Scribe_Values.Look(ref name, "playerFactionName"); def.ShouldSaveThings = true; Scribe_Deep.Look(ref def, "shipDefinition"); def.ShouldSaveThings = false; Scribe_Deep.Look <ResearchManager>(ref Current.Game.researchManager, false, "researchManager", new object[0]); Scribe_Deep.Look <TaleManager>(ref Current.Game.taleManager, false, "taleManager", new object[0]); Scribe_Deep.Look <UniqueIDsManager>(ref Current.Game.uniqueIDsManager, false, "uniqueIDsManager", new object[0]); Scribe_Deep.Look <TickManager>(ref Current.Game.tickManager, false, "tickManager", new object[0]); Scribe_Deep.Look <DrugPolicyDatabase>(ref Current.Game.drugPolicyDatabase, false, "drugPolicyDatabase", new object[0]); Scribe_Deep.Look <OutfitDatabase>(ref Current.Game.outfitDatabase, false, "outfitDatabase", new object[0]); Scribe_Deep.Look <PlayLog>(ref Current.Game.playLog, false, "playLog", new object[0]); })); def.Destroy(DestroyMode.Vanish); } return(true); }
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(); }
private static void LoadGameFromTmpSave(string fileName) { string str = GenText.ToCommaList(from mod in LoadedModManager.RunningMods select mod.ToString()); Log.Message("Loading game with colony " + fileName + " with mods " + str); MemoryUtility.ClearAllMapsAndWorld(); Current.Game = new Game(); Scribe.loader.InitLoading(FilePathForTmpSave()); ScribeMetaHeaderUtility.LoadGameDataHeader(ScribeMetaHeaderUtility.ScribeHeaderMode.Map, logVersionConflictWarning: true); if (Scribe.EnterNode("game")) { Current.Game = new Game(); Current.Game.LoadGame(); PermadeathModeUtility.CheckUpdatePermadeathModeUniqueNameOnGameLoad(fileName); } else { Log.Error("Could not find game XML node."); Scribe.ForceStop(); } RemoveTmpSave(); }
public static void SaveFromPathCall(Map map, IntVec3 startVec, LocalTargetInfo dest, TraverseParms traverseParms, PathEndMode peMode) { CellRect destinationRect; if (dest.HasThing && peMode != PathEndMode.OnCell) { destinationRect = dest.Thing.OccupiedRect(); } else { destinationRect = CellRect.SingleCell(dest.Cell); } var dumper = new PathDataLog { mapSize = map.Size, start = startVec, dest = destinationRect, peMode = peMode, tpMode = traverseParms.mode, tpMaxDanger = traverseParms.maxDanger, tpCanBash = traverseParms.canBash, tpMoveCardinal = traverseParms.pawn?.TicksPerMoveCardinal ?? -1, tpMoveDiagonal = traverseParms.pawn?.TicksPerMoveDiagonal ?? -1, pathGrid = map.pathGrid.pathGrid, fakeEdificeGrid = new ByteGrid(map), avoidGrid = traverseParms.pawn?.GetAvoidGrid(), allowedArea = traverseParms.pawn?.playerSettings?.AreaRestrictionInPawnCurrentMap }; foreach (var cell in map.AllCells) { var rb = cell.GetRegionBarrier(map); int value = Edifice_None; if (rb != null) { var door = rb as Building_Door; if (door != null) { switch (traverseParms.mode) { case TraverseMode.ByPawn: if (!traverseParms.canBash && door.IsForbiddenToPass(traverseParms.pawn)) { value = Edifice_NonTraversableDoor; } else if (!door.FreePassage) { value = door.PawnCanOpen(traverseParms.pawn) ? door.TicksToOpenNow : Edifice_NonTraversableDoor; } else { value = 0; } break; case TraverseMode.NoPassClosedDoors: value = !door.FreePassage ? Edifice_NonTraversableDoor : 0; break; } } else if ((rb as Building)?.PathFindCostFor(traverseParms.pawn) > 0) { value = Edifice_KnownArmedTrap; } else { value = Edifice_Impassible; } } dumper.fakeEdificeGrid[cell] = (byte)value; } var savePath = Path.Combine(GenFilePaths.DevOutputFolderPath, $"{traverseParms.pawn} - {Find.TickManager.TicksAbs}"); if (File.Exists(savePath + ".xml")) { savePath = savePath + " "; int saveNum = 1; while (File.Exists(savePath + saveNum + ".xml")) { saveNum++; } savePath = savePath + saveNum; } try { SaveGame(savePath); try { Scribe.InitWriting(savePath + ".xml", "PathDataLog"); } catch (Exception ex) { GenUI.ErrorDialog("Stuff went wrong " + ex); throw; } ScribeMetaHeaderUtility.WriteMetaHeader(); Scribe_Deep.LookDeep(ref dumper, "PathData"); } catch (Exception ex2) { Log.Error("Exception while saving: " + ex2); } finally { Scribe.FinalizeWriting(); } }
private static List <String> saveShip(List <Building> list, List <String> errors) { Log.Message("SAVE SHIP STARTED"); string saved_name = "ship_file_name"; try { foreach (Building building in list) { if (building.def == ThingDefOf.Ship_ComputerCore) { Log.Message("getting ship name"); Building_CustomShipComputerCore core = building as Building_CustomShipComputerCore; saved_name = core.outputname; Log.Message("ship name : " + saved_name); } } } catch (Exception e) { Log.Message("CUSTOM_SHIP_COMPUTER_CORE is not valid"); errors.Add("CUSTOM_SHIP_COMPUTER_CORE is not valid"); Log.Message(e.Message); } if (saved_name == "") { saved_name = "ship_file_name"; } string str1 = Path.Combine(GenFilePaths.SaveDataFolderPath, "Ships"); str1.Replace('/', '\\'); Log.Message("checking if folder exists : " + str1); if (!System.IO.Directory.Exists(str1)) { Log.Message("creating folder : " + str1); System.IO.Directory.CreateDirectory(str1); Log.Message("folder created successfully"); } int num = 0; string orstr2 = Path.Combine(str1, saved_name); Log.Message(orstr2); string str2 = orstr2 + ".rwship"; while (System.IO.File.Exists(str2)) { num++; str2 = orstr2 + num.ToString() + ".rwship"; } Log.Message(str2); SafeSaver.Save(str2, "RWShip", (Action)(() => { Log.Message("safesaver"); ScribeMetaHeaderUtility.WriteMetaHeader(); List <Pawn> launchedpawns = new List <Pawn>(); foreach (Building building in list) { if (building.def == ThingDefOf.Ship_CryptosleepCasket) { Building_CryptosleepCasket cask = building as Building_CryptosleepCasket; if (cask.HasAnyContents) { Pawn pawn = cask.ContainedThing as Pawn; launchedpawns.Add(pawn); } } } //start saving Scribe_Collections.Look <Building>(ref list, "buildings", LookMode.Deep); Scribe_Deep.Look <ResearchManager>(ref Current.Game.researchManager, false, "researchManager", new object[0]); Scribe_Deep.Look <UniqueIDsManager>(ref Current.Game.uniqueIDsManager, false, "uniqueIDsManager", new object[0]); Scribe_Deep.Look <DrugPolicyDatabase>(ref Current.Game.drugPolicyDatabase, false, "drugPolicyDatabase", new object[0]); Scribe_Deep.Look <OutfitDatabase>(ref Current.Game.outfitDatabase, false, "outfitDatabase", new object[0]); Scribe_Deep.Look <IdeoManager>(ref Current.Game.World.ideoManager, false, "ideo", new object[0]); // Scribe_Deep.Look<TaleManager>(ref Current.Game.taleManager, false, "taleManager", new object[0]); // Scribe_Deep.Look<PlayLog>(ref Current.Game.playLog, false, "playLog", new object[0]); int year = GenDate.YearsPassed; Log.Message("year:" + year); Scribe_Values.Look <int>(ref year, "currentyear", 0); List <Pawn> savedpawns = new List <Pawn>(); List <Pawn> mappawns = Current.Game.CurrentMap.mapPawns.AllPawns.ToList(); for (int i = 0; i < mappawns.Count; i++) { Pawn p = mappawns[i]; if (p == null) { continue; } if (p.Destroyed) { continue; } if (p.Faction != Faction.OfPlayer) { continue; } if (launchedpawns.Contains(p)) { continue; } Log.Message("rpawns:" + p.Name); savedpawns.Add(p); } for (int i = 0; i < Current.Game.World.worldPawns.AllPawnsAliveOrDead.Count(); i++) { Pawn efpawn = null; try { Pawn pawn = Current.Game.World.worldPawns.AllPawnsAliveOrDead.ElementAt(i); efpawn = pawn; if (pawn == null) { continue; } if (pawn.Destroyed) { continue; } Log.Message("world pawn:" + pawn.Name); if (pawn.Faction == Faction.OfPlayer) { Log.Message("colonistsaved:" + pawn.Name); savedpawns.Add(pawn); continue; } foreach (Pawn colonist in launchedpawns) { bool doo = false; if ( pawn.relations.DirectRelationExists(PawnRelationDefOf.Bond, colonist) || pawn.relations.DirectRelationExists(PawnRelationDefOf.Lover, colonist) || pawn.relations.DirectRelationExists(PawnRelationDefOf.Parent, colonist) || pawn.relations.DirectRelationExists(PawnRelationDefOf.Child, colonist) || pawn.relations.DirectRelationExists(PawnRelationDefOf.ExSpouse, colonist) || pawn.relations.DirectRelationExists(PawnRelationDefOf.Spouse, colonist) || pawn.relations.DirectRelationExists(PawnRelationDefOf.Fiance, colonist)) { doo = true; } if (pawn.relations.FamilyByBlood.Contains(colonist)) { doo = true; } if (doo) { Log.Message("relativeof:" + colonist.Name); pawn.SetFaction(Current.Game.World.factionManager.OfPlayer); savedpawns.Add(pawn); break; } } } catch (Exception e) { Log.Error("ERROR AT PAWN"); Log.Error(e.Message); errors.Add("ERROR AT PAWN"); errors.Add(e.Message); try { Log.Message(efpawn.Name.ToString()); errors.Add(efpawn.Name.ToString()); } catch (Exception innere) { Log.Error("cannot access its name"); errors.Add("cannot access its name"); Log.Message("innerebegin"); Log.Error(innere.Message); Log.Message("innereend"); } } } Log.Message("Finishing"); Log.Message("Current.Game.World.worldPawns.AllPawnsAliveOrDead.Count:" + Current.Game.World.worldPawns.AllPawnsAliveOrDead.Count()); Log.Message("savedpawns saving"); Scribe_Collections.Look <Pawn>(ref savedpawns, "oldpawns", LookMode.Deep); Log.Message("savedpawns saved successfully"); })); return(errors); }