IllusionMods / AnimationLoader

GNU General Public License v3.0
25 stars 3 forks source link

Better handle invalid/corrupted animation zipmods #34

Open ManlyMarco opened 1 month ago

ManlyMarco commented 1 month ago

Catch failed zipmod loads and provide a useful message to help debug the issue. Currently it's just:

XmlException: Data at the root level is invalid. Line 1, position 1. at System.Xml.XmlTextReaderImpl.Throw (System.Exception e) [0x00027] in <1d98d70bb7d8453b80c25aa561fdecd1>:0 at System.Xml.XmlTextReaderImpl.Throw (System.String res, System.String arg) [0x00029] in <1d98d70bb7d8453b80c25aa561fdecd1>:0 at System.Xml.XmlTextReaderImpl.Throw (System.String res) [0x00000] in <1d98d70bb7d8453b80c25aa561fdecd1>:0 at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace () [0x0012c] in <1d98d70bb7d8453b80c25aa561fdecd1>:0 at System.Xml.XmlTextReaderImpl.ParseDocumentContent () [0x002d4] in <1d98d70bb7d8453b80c25aa561fdecd1>:0 at System.Xml.XmlTextReaderImpl.Read () [0x0008c] in <1d98d70bb7d8453b80c25aa561fdecd1>:0 at System.Xml.XmlTextReader.Read () [0x00000] in <1d98d70bb7d8453b80c25aa561fdecd1>:0 at System.Xml.XmlReader.MoveToContent () [0x0003a] in <1d98d70bb7d8453b80c25aa561fdecd1>:0 at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderUsedAnimations.Read3_Animations () [0x00008] in <2ffcb7f16a044af3bc60f23de2c66c40>:0 at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&) at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in :0 Rethrow as InvalidOperationException: There is an error in XML document (1, 1). at System.Xml.Serialization.XmlSerializer.Deserialize (System.Xml.XmlReader xmlReader, System.String encodingStyle, System.Xml.Serialization.XmlDeserializationEvents events) [0x0011b] in <1d98d70bb7d8453b80c25aa561fdecd1>:0 at System.Xml.Serialization.XmlSerializer.Deserialize (System.Xml.XmlReader xmlReader, System.String encodingStyle) [0x00000] in <1d98d70bb7d8453b80c25aa561fdecd1>:0 at System.Xml.Serialization.XmlSerializer.Deserialize (System.IO.Stream stream) [0x0001c] in <1d98d70bb7d8453b80c25aa561fdecd1>:0 at AnimationLoader.UsedAnimations.Read () [0x00022] in <3ee9350102704cfea00069f47a558609>:0 at AnimationLoader.SwapAnim.Start () [0x00000] in <3ee9350102704cfea00069f47a558609>:0

Which later results in:

NullReferenceException: Object reference not set to an instance of an object at AnimationLoader.SwapAnim+Hooks.ExtendList (System.Object instance) [0x0003e] in <3ee9350102704cfea00069f47a558609>:0 at (wrapper dynamic-method) HSceneProc.DMD(HSceneProc) at (wrapper dynamic-method) HSceneProc.DMD(HSceneProc,bool) at (wrapper dynamic-method) HSceneProc+d153.DMD<HSceneProc+d153::MoveNext>(HSceneProc/d153) at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00026] in <548b4fa0e7e04f27a1b7580930bfb7dc>:0

It would help in cases like #33

IDontHaveIdea commented 4 weeks ago

Hi,

This is a utility file that saves the animations used for the "New" animation indicator functionality to work like the regular game animations.

at AnimationLoader.UsedAnimations.Read () [0x00022] in <3ee9350102704cfea00069f47a558609>:0

The file is readable since is xml but fixing it will depend on the user knowledge of xml. Thinking of just overwrite it since the only side effect is that the "New" symbol will appear again for all the AnimationLoader animations.

I'm doing a revision of the manifest.xml for the animations when done will upload a patched AnimationLoader with a new [katarsys] KPlug Animations vX.X.X.zipmod.