Browse Source

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

tags/v1.1.0
NGnius (Graham) 4 years ago
parent
commit
e8f59e8641
3 changed files with 7 additions and 2 deletions
  1. +2
    -0
      GamecraftModdingAPI/Persistence/DeserializeFromDiskEntitiesEnginePatch.cs
  2. +4
    -1
      GamecraftModdingAPI/Persistence/SaveAndLoadCompositionRootPatch.cs
  3. +1
    -1
      GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs

+ 2
- 0
GamecraftModdingAPI/Persistence/DeserializeFromDiskEntitiesEnginePatch.cs 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)
{
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;
Logging.MetaDebugLog($"dataPos: {originalPos}");
BinaryBufferReader bbr = new BinaryBufferReader(____bytesStream.ToArrayFast(out uint count), ____serializationData.dataPos);


+ 4
- 1
GamecraftModdingAPI/Persistence/SaveAndLoadCompositionRootPatch.cs View File

@@ -10,9 +10,12 @@ namespace GamecraftModdingAPI.Persistence
[HarmonyPatch(typeof(SaveAndLoadCompositionRoot), "Compose")]
class SaveAndLoadCompositionRootPatch
{
public static EnginesRoot currentEnginesRoot;

public static void Prefix(EnginesRoot enginesRoot)
{
SerializerManager.RegisterSerializers(enginesRoot);
currentEnginesRoot = enginesRoot;
//SerializerManager.RegisterSerializers(enginesRoot);
}
}
}

+ 1
- 1
GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs View File

@@ -62,7 +62,7 @@ namespace GamecraftModdingAPI.Tests
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 :(

Utility.VersionTracking.Enable();
//Utility.VersionTracking.Enable();//(very) unstable

// debug/test handlers
HandlerBuilder.Builder()


Loading…
Cancel
Save