IllusionMods / BepisPlugins

A collection of essential BepInEx plugins for games made by Illusion.
GNU General Public License v3.0
383 stars 82 forks source link

[EC] Save H scene does not work #91

Closed monophony-hub closed 4 years ago

monophony-hub commented 4 years ago

When I save a H scene what has some mods in EC, I got the following errors:

[Error : Unity Log] InvalidCastException: Specified cast is not valid. Stack trace: Sideloader.AutoResolver.UniversalAutoResolver+Hooks.ChaFileSaveFilePostHook (ChaFile __instance) (at <994eda44d51c464d919cea1c63d975ac>:0) (wrapper dynamic-method) ChaFile:SaveFile_Patch3 (ChaFile,System.IO.BinaryWriter,bool,int) ChaFileControl.SaveCharaFile (System.IO.BinaryWriter bw, System.Boolean savePng) (at :0) (wrapper dynamic-method) HEdit.HEditData:Save_Patch1 (HEdit.HEditData,System.IO.BinaryWriter,YS_Node.NodeControl,bool) HEdit.HEditData.Save (System.String _path, YS_Node.NodeControl _nodeControl, System.Boolean _isInitUserID) (at :0) HEdit.HEditSaveScene.m_5 (UniRx.Unit ) (at :0) UniRx.Observer+Subscribe1[T].OnNext (T value) (at <02df9929c9834d169bd727dbac5a500d>:0) UniRx.Operators.FromEventObservable1+FromEvent[TDelegate].OnNext () (at <02df9929c9834d169bd727dbac5a500d>:0) UnityEngine.Events.InvokableCall.Invoke () (at <2686255ceb974cc2967520f770810585>:0) UnityEngine.Events.UnityEvent.Invoke () (at <2686255ceb974cc2967520f770810585>:0) UnityEngine.UI.Button.Press () (at :0) UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at :0) UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at :0) UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at :0) UnityEngine.EventSystems.EventSystem:Update()

I found the code where the cast exception occurd.

In ChaFileSaveFilePostHook (Core.UAR.Hooks.cs)

var tmpExtInfo = (List<byte[]>)extData.data["info"];

This variable seems an instance of object[] on some chara card. With branching by type, the exception can not be occured. Like this:

if ( extData.data["info"] is List<byte[]>) { ... } else if ( extData.data["info"] is object[]) { ... }

But, I dont know this way is good or not?

ManlyMarco commented 4 years ago

Fixed in recent builds? @DeathWeasel1337

DeathWeasel1337 commented 4 years ago

Errors in ChaFileSaveFilePostHook should be fixed in the latest builds. Those errors were coming from version 1 and 2 ExtensibleSaveFormat data support. Code for this will now only run on Koikatsu since other games never had these versions.

TheloTheGreat commented 4 years ago

Hello, this issue still happens in Emotion Creators on the BepisPlugins 13.0.3 release, same stack trace.

ManlyMarco commented 4 years ago

The fix is not released yet. You can build from source to get the latest changes, or wait for a release.