ManlyMarco/KK_PantyFairy

Error loading ExtendedData

koindi opened this issue · 0 comments

Hi,

I'm not sure if this issue should be addressed here or is a KK_ExtendedData issue (or even a MessagePack problem), but I think it could easily fixed here.

When I try lo load a modified Savegame that includes ExtendedData from this plugin I've get this error:

[Error :PantyFairy] Could not deserialize field Progress because of error: Cannot cast from source type to destination type.

And the Plugin data is lost (quest is resetted). After hours of debuggin I've figured that the issue is because the python implementation of MessagePack (used by ExtendedData) serializes small numbers as 1 byte integers, while C# implementation keeps original variable size (4 bytes int). When C# deserialize the Python data, it returns a Byte type, that cannot be casted back to the int variable.

There is already a similar casting on the PantyFairySaveData() function.

if (fieldInfo.FieldType.IsEnum) val = (int)val;

It might be easy to implement similar cast for the int types size (1, 2, 4 and 8 bytes) but I don't know c# enough to do it by my self.