Skip to content

Commit

Permalink
Added extra log info to SaveDataManager
Browse files Browse the repository at this point in the history
  • Loading branch information
Nagord committed Jan 23, 2023
1 parent a687a7f commit d48e646
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 0 additions & 2 deletions PulsarModLoader/Patches/DebugReadout.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using HarmonyLib;
using PulsarModLoader.Chat.Commands;
using UnityEngine;
using UnityEngine.UI;

namespace PulsarModLoader.Patches
{
Expand Down
11 changes: 10 additions & 1 deletion PulsarModLoader/SaveData/SaveDataManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ public void SaveDatas(BinaryWriter writer)
//Save VersionID for later, starting with 0
writer.Write((uint)0);

//Bytecount for log
int TotalBytes = 0;


//save for mods
writer.Write(SaveCount); //int32 representing total configs
foreach (PMLSaveData saveData in SaveConfigs)
Expand All @@ -82,6 +86,7 @@ public void SaveDatas(BinaryWriter writer)
writer.Write(saveData.Identifier()); //Write PMLSaveData Identifier
writer.Write(saveData.VersionID); //Write PMLSaveData VersionID
writer.Write(modData.Length); //Write stream byte count
TotalBytes += modData.Length; //Add bytecount to log

//SaveData
if (modData.Length > 0)
Expand All @@ -100,6 +105,7 @@ public void SaveDatas(BinaryWriter writer)
}
writer.Write(ulong.MaxValue);
writer.Close();
Logger.Info($"PMLSaveManager has finished saving file. Bytes: {TotalBytes}");
}

public void LoadDatas(BinaryReader reader, bool ldarg3)
Expand All @@ -118,6 +124,8 @@ public void LoadDatas(BinaryReader reader, bool ldarg3)
string missingMods = "";
string VersionMismatchedMods = "";
string readMods = "";
int TotalBytes = 0;

for (int i = 0; i < count; i++)
{
//SaveDataHeader
Expand All @@ -127,6 +135,7 @@ public void LoadDatas(BinaryReader reader, bool ldarg3)
int bytecount = reader.ReadInt32(); //ByteCount
Logger.Info($"Reading SaveData: {harmonyIdent}::{SavDatIdent} SaveDataVersion: {VersionID} bytecount: {bytecount} Pos: {reader.BaseStream.Position}");
readMods += "\n" + harmonyIdent;
TotalBytes += bytecount;


bool foundReader = false;
Expand Down Expand Up @@ -163,7 +172,7 @@ public void LoadDatas(BinaryReader reader, bool ldarg3)

//Finish Reading
reader.Close();
Logger.Info("PMLSaveManager has finished reading file");
Logger.Info($"PMLSaveManager has finished reading file. Bytes: {TotalBytes}");
ReadMods = readMods;

if (missingMods.Length > 0)
Expand Down

0 comments on commit d48e646

Please sign in to comment.