From 3508b9d21bc923470b20a94375b6b485b62e6c68 Mon Sep 17 00:00:00 2001 From: Mc-muffin Date: Sun, 26 Jul 2020 17:35:17 -0500 Subject: [PATCH] Fix Bytecode 15 code editing Fixes the variable re-assigning issue in which adding more than 1 new variable in the code editor would make the new vars be duplicates of the last assigned one in bytecode 15 games. --- UndertaleModLib/UndertaleData.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/UndertaleModLib/UndertaleData.cs b/UndertaleModLib/UndertaleData.cs index 61ab49d94..928d200c5 100644 --- a/UndertaleModLib/UndertaleData.cs +++ b/UndertaleModLib/UndertaleData.cs @@ -257,14 +257,15 @@ public static UndertaleVariable EnsureDefined(this IList list if (!bytecode14) { if (data.InstanceVarCount == data.InstanceVarCountAgain) - { // Example games that use this mode: Undertale v1.08, Undertale v1.11. + { // Bytecode 16+. data.InstanceVarCount++; data.InstanceVarCountAgain++; } else - { // Example Games which use this mode: Undertale v1.001. - if (inst == UndertaleInstruction.InstanceType.Self) + { // Bytecode 15. + if (inst == UndertaleInstruction.InstanceType.Self && !isBuiltin) { + oldId = data.InstanceVarCountAgain; data.InstanceVarCountAgain++; } else if (inst == UndertaleInstruction.InstanceType.Global)