diff --git a/gtk-sharp/MapWindow.cs b/gtk-sharp/MapWindow.cs index f048bdb..c6a2d3a 100644 --- a/gtk-sharp/MapWindow.cs +++ b/gtk-sharp/MapWindow.cs @@ -978,6 +978,7 @@ bool SaveAs() { d.CurrentName = Level.Name + ".sceA"; d.DoOverwriteConfirmation = true; try { + Level.Validate(); if (d.Run() == (int) ResponseType.Accept) { mapfile = new MapFile(); Level.AssurePlayerStart(); @@ -1014,6 +1015,7 @@ bool Save() { } else { bool success = false; try { + Level.Validate(); Level.AssurePlayerStart(); Redraw(); mapfile.Directory[0] = Level.Save(); diff --git a/level/Level.cs b/level/Level.cs index 17e1601..a900aa8 100644 --- a/level/Level.cs +++ b/level/Level.cs @@ -347,6 +347,29 @@ public void AssurePlayerStart() { } } + void ValidatePlatformTriggers() { + for (int i = 0; i < Polygons.Count; ++i) { + Polygon polygon = Polygons[i]; + if (polygon.Type == PolygonType.PlatformOnTrigger || polygon.Type == PolygonType.PlatformOffTrigger) { + bool found = false; + foreach (Platform platform in Platforms) { + if (platform.PolygonIndex == polygon.Permutation) { + found = true; + break; + } + } + if (!found) { + string message = "Invalid map: Platform trigger at polygon " + i + " does not have a valid platform assigned."; + throw new Wadfile.BadMapException(message); + } + } + } + } + + public void Validate() { + ValidatePlatformTriggers(); + } + public Wadfile.DirectoryEntry Save() { Wadfile.DirectoryEntry wad = new Wadfile.DirectoryEntry(); wad.Chunks = Chunks;