diff --git a/IPA.Loader/Config/Stores/GeneratedStoreImpl/Correction.cs b/IPA.Loader/Config/Stores/GeneratedStoreImpl/Correction.cs index 94a989a9..127d7c65 100644 --- a/IPA.Loader/Config/Stores/GeneratedStoreImpl/Correction.cs +++ b/IPA.Loader/Config/Stores/GeneratedStoreImpl/Correction.cs @@ -27,7 +27,13 @@ namespace IPA.Config.Stores var expectType = GetExpectedValueTypeForType(memberType); if (expectType == typeof(Map)) // TODO: make this slightly saner + { + if (expectType.IsValueType) + { // custom value type + return ReadObjectMembers(memberType).Any(NeedsCorrection); + } return true; + } return false; } @@ -86,6 +92,17 @@ namespace IPA.Config.Stores var valueLocal = GetLocal(convType); il.Emit(OpCodes.Stloc, valueLocal); + void LdlocaValueLocal(ILGenerator il) + => il.Emit(OpCodes.Ldloca, valueLocal); + + foreach (var mem in structure) + { + if (NeedsCorrection(mem)) + EmitLoadCorrectStore(il, mem, shouldLock, alwaysNew, GetLocal, + LdlocaValueLocal, LdlocaValueLocal, parentobj); + } + + il.Emit(OpCodes.Ldloc, valueLocal); } if (member.IsNullable) diff --git a/IPA.Loader/Config/Stores/GeneratedStoreImpl/MakeCreator.cs b/IPA.Loader/Config/Stores/GeneratedStoreImpl/MakeCreator.cs index 00ec352b..3b584f15 100644 --- a/IPA.Loader/Config/Stores/GeneratedStoreImpl/MakeCreator.cs +++ b/IPA.Loader/Config/Stores/GeneratedStoreImpl/MakeCreator.cs @@ -124,7 +124,8 @@ namespace IPA.Config.Stores foreach (var member in structure) { - EmitLoadCorrectStore(il, member, false, true, GetLocal, GetMethodThis, GetMethodThis, GetMethodThis); + if (NeedsCorrection(member)) + EmitLoadCorrectStore(il, member, false, true, GetLocal, GetMethodThis, GetMethodThis, GetMethodThis); } il.Emit(OpCodes.Pop);