Skip to content

Commit

Permalink
Add map issue check for a trigger using "Entered by..." without being…
Browse files Browse the repository at this point in the history
… attached to anything
  • Loading branch information
Rampastring committed Jun 4, 2023
1 parent 970186c commit 8f86e05
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/TSMapEditor/Models/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,29 @@ public List<string> CheckForIssues()
}
}

// Check for triggers using the "Entered by" event without being attached to anything
const int EnteredByConditionIndex = 1;
foreach (var trigger in Triggers)
{
if (!trigger.Conditions.Exists(c => c.ConditionIndex == EnteredByConditionIndex))
continue;

var tag = Tags.Find(t => t.Trigger == trigger);
if (tag == null)
continue;

if (!Structures.Exists(s => s.AttachedTag == tag) &&
!Infantry.Exists(i => i.AttachedTag == tag) &&
!Units.Exists(u => u.AttachedTag == tag) &&
!Aircraft.Exists(a => a.AttachedTag == tag) &&
!TeamTypes.Exists(tt => tt.Tag == tag) &&
!CellTags.Exists(ct => ct.Tag == tag) &&
!Triggers.Exists(otherTrigger => otherTrigger.LinkedTrigger == trigger))
{
issueList.Add($"Trigger '{trigger.Name}' is using the \"Entered by...\" event without being attached to any object, cell, or team. Did you forget to attach it?");
}
}

return issueList;
}

Expand Down

0 comments on commit 8f86e05

Please sign in to comment.