Skip to content

Commit e90e834

Browse files
Merge pull request #8 from PolyTech-Modding/better_layout_saving
fixed layout saving
2 parents 8f9a04a + ddd119e commit e90e834

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

PolyTechMain.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class PolyTechMain : PolyTechMod
2424
public new const string
2525
PluginGuid = "polytech.polytechframework",
2626
PluginName = "PolyTech Framework",
27-
PluginVersion = "0.9.4";
27+
PluginVersion = "0.9.5";
2828
private static BindingList<PolyTechMod>
2929
noncheatMods = new BindingList<PolyTechMod> { },
3030
cheatMods = new BindingList<PolyTechMod> { };
@@ -707,7 +707,7 @@ static void patchSerializerOne(SandboxLayoutData __instance, List<byte> bytes)
707707
{
708708
ptfInstance.ptfLogger.LogMessage($"Layout pre version: {__instance.m_Version}");
709709
if (GameStateManager.GetState() != GameState.BUILD && GameStateManager.GetState() != GameState.SANDBOX) return;
710-
if (noncheatMods.Where(x => x.shouldSaveData).Count() + cheatMods.Where(x => x.shouldSaveData).Count() == 0) return;
710+
if (noncheatMods.Where(x => x.shouldSaveData).Count() + cheatMods.Where(x => x.isEnabled).Count() == 0) return;
711711
__instance.m_Version *= -1;
712712
//PopUpMessage.Display("You have cheat mods enabled, do you want to store them?\n(This will make the layout incompatible with vanilla PB2)", yes, no);
713713
ptfInstance.ptfLogger.LogMessage($"Version after cheat question: {__instance.m_Version.ToString()}");
@@ -732,7 +732,10 @@ private static void patchSerializerTwo(SandboxLayoutData __instance, List<byte>
732732
if (__instance.m_Version >= 0) return;
733733
bytes.AddRange(ByteSerializer.SerializeStrings(mods));
734734

735-
bytes.AddRange(ByteSerializer.SerializeInt(modData.Count));
735+
// add an int indicating the number of mods that will save binary data
736+
int modsSavingBinary = noncheatMods.Where(x => x.shouldSaveData).Count() + cheatMods.Where(x => x.shouldSaveData).Count();
737+
bytes.AddRange(ByteSerializer.SerializeInt(modsSavingBinary));
738+
736739
foreach (var mod in noncheatMods){
737740
if (mod.isEnabled && mod.shouldSaveData){
738741
bytes.AddRange(ByteSerializer.SerializeString(

0 commit comments

Comments
 (0)