From c6a1b7b10dad16dbb8d568b3009ff39562da501d Mon Sep 17 00:00:00 2001 From: Starkku Date: Tue, 22 Jul 2025 20:43:53 +0300 Subject: [PATCH 1/2] Fix trigger event ID validation relying on amount of event types vs. actually checking for IDs --- src/TSMapEditor/Models/Trigger.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/TSMapEditor/Models/Trigger.cs b/src/TSMapEditor/Models/Trigger.cs index fe261003a..20dcd2a1f 100644 --- a/src/TSMapEditor/Models/Trigger.cs +++ b/src/TSMapEditor/Models/Trigger.cs @@ -2,6 +2,7 @@ using Rampastring.Tools; using System; using System.Collections.Generic; +using TSMapEditor.CCEngine; using TSMapEditor.Misc; using TSMapEditor.Models.Enums; @@ -179,12 +180,12 @@ public void ParseConditions(string data, EditorConfig editorConfig) for (int i = 0; i < eventCount; i++) { int conditionIndex = Conversions.IntFromString(dataArray[startIndex], -1); - if (conditionIndex >= editorConfig.TriggerEventTypes.Count) + if (!editorConfig.TriggerEventTypes.TryGetValue(conditionIndex, out TriggerEventType value)) { throw new INIConfigException("The map contains a trigger event that is not defined in the editor's config. To prevent data loss, the map cannot be loaded. Event index: " + conditionIndex); } - bool usesP3 = editorConfig.TriggerEventTypes[conditionIndex].UsesP3; + bool usesP3 = value.UsesP3; var triggerEvent = TriggerCondition.ParseFromArray(dataArray, startIndex, usesP3); if (triggerEvent == null) From 5389f735db70665e6e5f80980a62d78a883f434a Mon Sep 17 00:00:00 2001 From: Rami Pasanen Date: Mon, 28 Jul 2025 15:16:36 +0300 Subject: [PATCH 2/2] Rename variable name to be more descriptive --- src/TSMapEditor/Models/Trigger.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TSMapEditor/Models/Trigger.cs b/src/TSMapEditor/Models/Trigger.cs index 20dcd2a1f..b502fd30d 100644 --- a/src/TSMapEditor/Models/Trigger.cs +++ b/src/TSMapEditor/Models/Trigger.cs @@ -180,12 +180,12 @@ public void ParseConditions(string data, EditorConfig editorConfig) for (int i = 0; i < eventCount; i++) { int conditionIndex = Conversions.IntFromString(dataArray[startIndex], -1); - if (!editorConfig.TriggerEventTypes.TryGetValue(conditionIndex, out TriggerEventType value)) + if (!editorConfig.TriggerEventTypes.TryGetValue(conditionIndex, out TriggerEventType triggerEventType)) { throw new INIConfigException("The map contains a trigger event that is not defined in the editor's config. To prevent data loss, the map cannot be loaded. Event index: " + conditionIndex); } - bool usesP3 = value.UsesP3; + bool usesP3 = triggerEventType.UsesP3; var triggerEvent = TriggerCondition.ParseFromArray(dataArray, startIndex, usesP3); if (triggerEvent == null)