Skip to content

Commit c6a1b7b

Browse files
committed
Fix trigger event ID validation relying on amount of event types vs. actually checking for IDs
1 parent 646a65a commit c6a1b7b

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/TSMapEditor/Models/Trigger.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Rampastring.Tools;
33
using System;
44
using System.Collections.Generic;
5+
using TSMapEditor.CCEngine;
56
using TSMapEditor.Misc;
67
using TSMapEditor.Models.Enums;
78

@@ -179,12 +180,12 @@ public void ParseConditions(string data, EditorConfig editorConfig)
179180
for (int i = 0; i < eventCount; i++)
180181
{
181182
int conditionIndex = Conversions.IntFromString(dataArray[startIndex], -1);
182-
if (conditionIndex >= editorConfig.TriggerEventTypes.Count)
183+
if (!editorConfig.TriggerEventTypes.TryGetValue(conditionIndex, out TriggerEventType value))
183184
{
184185
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);
185186
}
186187

187-
bool usesP3 = editorConfig.TriggerEventTypes[conditionIndex].UsesP3;
188+
bool usesP3 = value.UsesP3;
188189

189190
var triggerEvent = TriggerCondition.ParseFromArray(dataArray, startIndex, usesP3);
190191
if (triggerEvent == null)

0 commit comments

Comments
 (0)