MaFi-Games/Captain-of-Industry-issues

Deserailization

DeznekCZ opened this issue · 3 comments

Issue description

The version 0.8 of mod Programable Network was yesterday working normally, one of saves I could load.
But after no changes in serialization the mod stopped working:

Mafi.Serialization.CorruptedSaveException: Failed to finalize deserialization of 'Transport #0' (type 'Transport'. Previous deserialized object: Computer #48328 (type Computer) ---> Mafi.Serialization.CorruptedSaveException: Deserialized object has type 'VirtualProductProto' but type 'LystMutableDuringIter`1' was expected. ToString returned 'Product_Virtual_Heat (virtual)'.
  at Mafi.Serialization.BlobReader.TryStartClassDeserialization[T] (T& obj, System.Func`3[T1,T2,TResult] customNewObjFactory) [0x000b3]  
  at Mafi.Collections.LystMutableDuringIter`1[T].Deserialize (Mafi.Serialization.BlobReader reader) [0x00000]  
  at (wrapper dynamic-method) System.Object.lambda_method(System.Runtime.CompilerServices.Closure,Mafi.Serialization.BlobReader)
  at Mafi.Serialization.BlobReader.ReadGenericAs[T] () [0x0002f]  
  at Mafi.Option`1[T].Deserialize (Mafi.Serialization.BlobReader reader) [0x0000e]  
  at Mafi.Core.Entities.Entity.DeserializeData (Mafi.Serialization.BlobReader reader) [0x00053]  
  at Mafi.Core.Entities.Static.StaticEntity.DeserializeData (Mafi.Serialization.BlobReader reader) [0x00000]  
  at Mafi.Core.Factory.Transports.Transport.DeserializeData (Mafi.Serialization.BlobReader reader) [0x00000]  
  at Mafi.Core.Factory.Transports.Transport+<>c.<.cctor>b__204_1 (System.Object obj, Mafi.Serialization.BlobReader reader) [0x00000]  
  at Mafi.Serialization.BlobReader+<FinalizeLoadingTimeSliced>d__30.MoveNext () [0x00062]  
   --- End of inner exception stack trace ---
  at Mafi.Serialization.BlobReader+<FinalizeLoadingTimeSliced>d__30.MoveNext () [0x000f3]  
  at Mafi.Core.SaveGame.GameLoader+<FinishGameLoadAndDisposeTimeSliced>d__7.MoveNext () [0x002ae]  
  at Mafi.Core.Game.GameBuilder+<BuildLoadedGameTimeSliced>d__3.MoveNext () [0x002e8]  
  at Mafi.Unity.GamePlayScene+<loadGame>d__21.MoveNext () [0x00296]  
  at Mafi.Unity.GamePlayScene+<Initialize>d__18.MoveNext () [0x000a5]  
  at Mafi.Unity.Main+<unloadAndStartNewScene>d__70.MoveNext () [0x000fc]  
  at Mafi.Unity.Main.stepSceneInitialization () [0x000dc]  

Reproduction steps

  1. load for example save 0.8-comp
  2. build next computer or cable
  3. save
  4. do not reload again (save with already build pipes from yesterday is loaded succesfully)

Game version and build number

v0.6.4d b343

Operating system

Windows

Attachments

All affected saves.zip
MultiplayerContracts_0.2.zip
ProgramableNetwork_0.8.zip
ProgramableNetwork_0.8b.zip

Reprosteps update:

  1. create save without any computer
  2. build computer or cables in any count
  3. save
  4. load
  5. save
  6. next load is corrupted

I did try defining custom Phantom product proto and user ProductType.NONE, it did not work for both cases.
Still the main issue is showing.
I saw:

        //
        // Souhrn:
        //     This method is called - on load - when we change ports after upgrade - any port
        //     changes connection Any class that holds IoPortData or IoPort needs to implement
        //     this! IMPORTANT: This is not called from ctor, so any code performed in this
        //     method should be performed in super ctor as well.
        protected virtual void OnPortsLoadOrChange()
        {
        }

But there is no requirement to implement this function, because the IO is written manually when EntitySimUpdate.

Is propably caused by runtime error in new type of transport:

E 10:03:21,223 S4922441 ~Mai: Nope
  at Mafi.Unity.Factory.Transports.TransportMb.Mafi.Unity.Entities.IEntityMbWithSyncUpdate.SyncUpdate (Mafi.Core.GameTime time) [0x00000]  
  at Mafi.Unity.Entities.MbBasedEntitiesRenderer.SyncUpdate (Mafi.Core.GameTime time) [0x00000]  
  at Mafi.Unity.Entities.EntitiesRenderingManager.syncUpdate (Mafi.Core.GameTime time) [0x00000]  
  at Mafi.EventNonSaveable`1[T].Invoke (T arg) [0x00000]  
  at Mafi.EventNonSaveable`1[T].InvokeTraced (T arg, System.String traceCategory) [0x00000]  
  at Mafi.Core.GameLoop.GameLoopEvents.InvokeSyncUpdate (Mafi.Core.GameTime gameTime) [0x00000]  
  at Mafi.Core.GameLoop.GameRunner.performSyncUpdate () [0x00000]  
  at Mafi.Core.GameLoop.GameRunner.performSyncAndStartSim (System.Single deltaTimeMs) [0x00000]  
  at Mafi.Core.GameLoop.GameRunner.Update (Mafi.Fix32 deltaTimeMs) [0x00000]  
  at Mafi.Unity.GamePlayScene.Update (Mafi.Fix32 deltaMs) [0x00000]