Delay serializer registration and disable version check even in Debug mode to fix #5

This commit is contained in:
NGnius (Graham) 2020-05-21 19:40:46 -04:00
parent 8326d70cbf
commit e8f59e8641
3 changed files with 7 additions and 2 deletions

View file

@ -22,6 +22,8 @@ namespace GamecraftModdingAPI.Persistence
public static void Prefix(ref ISerializationData ____serializationData, ref FasterList<byte> ____bytesStream, ref IEntitySerialization ____entitySerializer, bool ____spawnBlocksOnly) public static void Prefix(ref ISerializationData ____serializationData, ref FasterList<byte> ____bytesStream, ref IEntitySerialization ____entitySerializer, bool ____spawnBlocksOnly)
{ {
if (____spawnBlocksOnly) return; // only run after second deserialization call (when all vanilla stuff is already deserialized) if (____spawnBlocksOnly) return; // only run after second deserialization call (when all vanilla stuff is already deserialized)
if (SaveAndLoadCompositionRootPatch.currentEnginesRoot == null) return;
SerializerManager.RegisterSerializers(SaveAndLoadCompositionRootPatch.currentEnginesRoot);
uint originalPos = ____serializationData.dataPos; uint originalPos = ____serializationData.dataPos;
Logging.MetaDebugLog($"dataPos: {originalPos}"); Logging.MetaDebugLog($"dataPos: {originalPos}");
BinaryBufferReader bbr = new BinaryBufferReader(____bytesStream.ToArrayFast(out uint count), ____serializationData.dataPos); BinaryBufferReader bbr = new BinaryBufferReader(____bytesStream.ToArrayFast(out uint count), ____serializationData.dataPos);

View file

@ -10,9 +10,12 @@ namespace GamecraftModdingAPI.Persistence
[HarmonyPatch(typeof(SaveAndLoadCompositionRoot), "Compose")] [HarmonyPatch(typeof(SaveAndLoadCompositionRoot), "Compose")]
class SaveAndLoadCompositionRootPatch class SaveAndLoadCompositionRootPatch
{ {
public static EnginesRoot currentEnginesRoot;
public static void Prefix(EnginesRoot enginesRoot) public static void Prefix(EnginesRoot enginesRoot)
{ {
SerializerManager.RegisterSerializers(enginesRoot); currentEnginesRoot = enginesRoot;
//SerializerManager.RegisterSerializers(enginesRoot);
} }
} }
} }

View file

@ -62,7 +62,7 @@ namespace GamecraftModdingAPI.Tests
Logging.MetaDebugLog("Audio Mixers: "+string.Join(",", AudioTools.GetMixers())); Logging.MetaDebugLog("Audio Mixers: "+string.Join(",", AudioTools.GetMixers()));
//AudioTools.SetVolume(0.0f, "Music"); // The game now sets this from settings again after this is called :( //AudioTools.SetVolume(0.0f, "Music"); // The game now sets this from settings again after this is called :(
Utility.VersionTracking.Enable(); //Utility.VersionTracking.Enable();//(very) unstable
// debug/test handlers // debug/test handlers
HandlerBuilder.Builder() HandlerBuilder.Builder()