From b4f4e86277ff53ced8614b1bb7ff65a3150c7283 Mon Sep 17 00:00:00 2001 From: haven1433 Date: Tue, 4 Oct 2022 23:05:32 -0500 Subject: [PATCH] don't clear the newgame pokemon tables These were being cleared because they existed within scripts. Make the script ClearFormat logic smarter so it skips tables that align to single arguments. --- src/HexManiac.Core/Models/Code/ScriptParser.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/HexManiac.Core/Models/Code/ScriptParser.cs b/src/HexManiac.Core/Models/Code/ScriptParser.cs index ae9eddfa..323e1536 100644 --- a/src/HexManiac.Core/Models/Code/ScriptParser.cs +++ b/src/HexManiac.Core/Models/Code/ScriptParser.cs @@ -111,7 +111,13 @@ namespace HavenSoft.HexManiac.Core.Models.Code { if (arg.Type != ArgType.Pointer) { // there may've previously been a pointer here: the code has changed! // when clearing args, we actually _do_ want to clear any anchors that point to them. - model.ClearFormat(token, address + length, arg.Length(model, address + length)); + var start = address + length; + var argLength = arg.Length(model, start); + if (model.GetNextRun(start) is ITableRun tableRun && tableRun.Start == start && tableRun.Length == argLength) { + // no need to clear + } else { + model.ClearFormat(token, start, argLength); + } } else { var destination = model.ReadPointer(address + length); if (destination >= 0 && destination < model.Count) {