Skip to content

Commit

Permalink
Merge pull request #291 from edbmods/version-1.1.8
Browse files Browse the repository at this point in the history
Version 1.1.8
  • Loading branch information
edbmods authored Mar 13, 2020
2 parents 1376b3d + 41a9f4d commit 62fd74f
Show file tree
Hide file tree
Showing 7 changed files with 874 additions and 3 deletions.
2 changes: 2 additions & 0 deletions EdBPrepareCarefully.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@
<Compile Include="Source\CarefullyPawnRelationDef.cs" />
<Compile Include="Source\UtilityCopy.cs" />
<Compile Include="Source\ExtensionsObject.cs" />
<Compile Include="Source\Version4\ColonistLoaderVersion4.cs" />
<Compile Include="Source\Version4\PresetLoaderVersion4.cs" />
<Compile Include="Source\Version4\SaveRecordAlienV4.cs" />
<Compile Include="Source\Version4\SaveRecordFactionV4.cs" />
<Compile Include="Source\Version3\PresetLoaderVersion3.cs" />
Expand Down
2 changes: 1 addition & 1 deletion Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
[assembly: AssemblyVersion("1.1.1")]

// Increment for each new release
[assembly: AssemblyFileVersion("1.1.7")]
[assembly: AssemblyFileVersion("1.1.8")]
2 changes: 1 addition & 1 deletion Resources/About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@

If you get a set of starting colonists that you like, save them as a preset so that you can start your game the same way next time.

[Version 1.1.7]
[Version 1.1.8]
</description>
</ModMetaData>
2 changes: 1 addition & 1 deletion Resources/About/Manifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manifest>
<identifier>EdBPrepareCarefully</identifier>
<version>1.1.7</version>
<version>1.1.8</version>
<loadAfter>
<li>Core</li>
<li>HugsLib</li>
Expand Down
7 changes: 7 additions & 0 deletions Resources/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
_____________________________________________________________________________

Version 1.1.8
_____________________________________________________________________________

- Fixed compatibility issue with Psychology and Facial Stuff mods.

_____________________________________________________________________________

Version 1.1.7
Expand Down
66 changes: 66 additions & 0 deletions Source/Version4/ColonistLoaderVersion4.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Verse;


namespace EdB.PrepareCarefully {
public class ColonistLoaderVersion4 {
public CustomPawn Load(PrepareCarefully loadout, string name) {
SaveRecordPawnV4 pawnRecord = new SaveRecordPawnV4();
string modString = "";
string version = "";
try {
Scribe.loader.InitLoading(ColonistFiles.FilePathForSavedColonist(name));
Scribe_Values.Look<string>(ref version, "version", "unknown", false);
Scribe_Values.Look<string>(ref modString, "mods", "", false);

try {
Scribe_Deep.Look<SaveRecordPawnV4>(ref pawnRecord, "pawn", null);
}
catch (Exception e) {
Messages.Message(modString, MessageTypeDefOf.SilentInput);
Messages.Message("EdB.PC.Dialog.PawnPreset.Error.Failed".Translate(), MessageTypeDefOf.RejectInput);
Log.Warning(e.ToString());
Log.Warning("Colonist was created with the following mods: " + modString);
return null;
}
}
catch (Exception e) {
Log.Error("Failed to load preset file");
throw e;
}
finally {
PresetLoader.ClearSaveablesAndCrossRefs();
}

if (pawnRecord == null) {
Messages.Message(modString, MessageTypeDefOf.SilentInput);
Messages.Message("EdB.PC.Dialog.PawnPreset.Error.Failed".Translate(), MessageTypeDefOf.RejectInput);
Log.Warning("Colonist was created with the following mods: " + modString);
return null;
}

PresetLoaderVersion4 loader = new PresetLoaderVersion4();
CustomPawn loadedPawn = loader.LoadPawn(pawnRecord);
if (loadedPawn != null) {
CustomPawn idConflictPawn = PrepareCarefully.Instance.Pawns.FirstOrDefault((CustomPawn p) => {
return p.Id == loadedPawn.Id;
});
if (idConflictPawn != null) {
loadedPawn.GenerateId();
}
return loadedPawn;
}
else {
loadout.State.AddError(modString);
loadout.State.AddError("EdB.PC.Dialog.Preset.Error.NoCharacter".Translate());
Log.Warning("Preset was created with the following mods: " + modString);
return null;
}
}
}
}

Loading

0 comments on commit 62fd74f

Please sign in to comment.