From 1636be7be63ba7531356d8c9fd485ce12cf6a78a Mon Sep 17 00:00:00 2001 From: MaxED Date: Thu, 7 Apr 2016 08:40:23 +0000 Subject: [PATCH] Added, Game configurations: added "Polyobject number":25 argument type. When set, used polyobject numbers will be displayed in the action argument dropdown. Added, Map Analysis mode: Polyobj_ExplicitLine action was not checked by "Check polyobjects" check. Updated ZDoom_linedefs.cfg and Hexen_linedefs.cfg (polyobject number linedef args now have type 25). Updated documentation ("Game Configuration - Action Argument Settings"). --- .../Includes/Hexen_linedefs.cfg | 68 +++++++++++-------- .../Includes/ZDoom_linedefs.cfg | 31 +++++---- Help/gc_argumentsettings.html | 5 +- Source/Core/Builder.csproj | 1 + Source/Core/Types/LinedefTagHandler.cs | 2 +- Source/Core/Types/PolyobjectNumberHandler.cs | 51 ++++++++++++++ Source/Core/Types/SectorTagHandler.cs | 8 +-- Source/Core/Types/ThingTagHandler.cs | 2 +- Source/Core/Types/UniversalType.cs | 1 + .../ErrorChecks/CheckPolyobjects.cs | 39 ++++++++--- 10 files changed, 152 insertions(+), 56 deletions(-) create mode 100644 Source/Core/Types/PolyobjectNumberHandler.cs diff --git a/Build/Configurations/Includes/Hexen_linedefs.cfg b/Build/Configurations/Includes/Hexen_linedefs.cfg index 3dd84d31..d01964c5 100644 --- a/Build/Configurations/Includes/Hexen_linedefs.cfg +++ b/Build/Configurations/Includes/Hexen_linedefs.cfg @@ -11,22 +11,24 @@ misc polyobj { - title = "Polyobj"; + title = "Polyobjects"; 1 { - title = "Polyobj Start Line"; + title = "Polyobject Start Line"; id = "Polyobj_StartLine"; requiresactivation = false; arg0 { - title = "Polyobj Number"; + title = "Polyobject Number"; + type = 25; } arg1 { - title = "Mirror Polyobj Number"; + title = "Mirror Polyobject Number"; + type = 25; } arg2 @@ -37,12 +39,13 @@ polyobj 2 { - title = "Polyobj Rotate Left"; + title = "Polyobject Rotate Left"; id = "Polyobj_RotateLeft"; arg0 { - title = "Polyobj Number"; + title = "Polyobject Number"; + type = 25; } arg1 @@ -63,12 +66,13 @@ polyobj 3 { - title = "Polyobj Rotate Right"; + title = "Polyobject Rotate Right"; id = "Polyobj_RotateRight"; arg0 { - title = "Polyobj Number"; + title = "Polyobject Number"; + type = 25; } arg1 @@ -89,12 +93,13 @@ polyobj 4 { - title = "Polyobj Move"; + title = "Polyobject Move"; id = "Polyobj_Move"; arg0 { - title = "Polyobj Number"; + title = "Polyobject Number"; + type = 25; } arg1 @@ -120,13 +125,14 @@ polyobj 5 { - title = "Polyobj Explicit Line"; + title = "Polyobject Explicit Line"; id = "Polyobj_ExplicitLine"; requiresactivation = false; arg0 { - title = "Polyobj Number"; + title = "Polyobject Number"; + type = 25; } arg1 @@ -136,7 +142,8 @@ polyobj arg2 { - title = "Mirror Polyobj Number"; + title = "Mirror Polyobject Number"; + type = 25; } arg3 @@ -147,12 +154,13 @@ polyobj 6 { - title = "Polyobj Move (* 8)"; + title = "Polyobject Move (* 8)"; id = "Polyobj_MoveTimes8"; arg0 { - title = "Polyobj Number"; + title = "Polyobject Number"; + type = 25; } arg1 @@ -178,12 +186,13 @@ polyobj 7 { - title = "Polyobj Door Swing"; + title = "Polyobject Door Swing"; id = "Polyobj_DoorSwing"; arg0 { - title = "Polyobj Number"; + title = "Polyobject Number"; + type = 25; } arg1 @@ -211,12 +220,13 @@ polyobj 8 { - title = "Polyobj Door Slide"; + title = "Polyobject Door Slide"; id = "Polyobj_DoorSlide"; arg0 { - title = "Polyobj Number"; + title = "Polyobject Number"; + type = 25; } arg1 @@ -250,12 +260,13 @@ polyobj 90 { - title = "Polyobj Rotate Left (override)"; + title = "Polyobject Rotate Left (override)"; id = "Polyobj_OR_RotateLeft"; arg0 { - title = "Polyobj Number"; + title = "Polyobject Number"; + type = 25; } arg1 @@ -276,12 +287,13 @@ polyobj 91 { - title = "Polyobj Rotate Right (override)"; + title = "Polyobject Rotate Right (override)"; id = "Polyobj_OR_RotateRight"; arg0 { - title = "Polyobj Number"; + title = "Polyobject Number"; + type = 25; } arg1 @@ -302,12 +314,13 @@ polyobj 92 { - title = "Polyobj Move (override)"; + title = "Polyobject Move (override)"; id = "Polyobj_OR_Move"; arg0 { - title = "Polyobj Number"; + title = "Polyobject Number"; + type = 25; } arg1 @@ -333,12 +346,13 @@ polyobj 93 { - title = "Polyobj Move (8mu, override)"; + title = "Polyobject Move (8mu, override)"; id = "Polyobj_OR_MoveTimes8"; arg0 { - title = "Polyobj Number"; + title = "Polyobject Number"; + type = 25; } arg1 diff --git a/Build/Configurations/Includes/ZDoom_linedefs.cfg b/Build/Configurations/Includes/ZDoom_linedefs.cfg index 60b8ac26..54683973 100644 --- a/Build/Configurations/Includes/ZDoom_linedefs.cfg +++ b/Build/Configurations/Includes/ZDoom_linedefs.cfg @@ -460,15 +460,16 @@ zdoom { polyobj { - title = "Polyobject"; + title = "Polyobjects"; 59 { - title = "Polyobj Move to Spot (override)"; + title = "Polyobject Move to Spot (override)"; id = "Polyobj_OR_MoveToSpot"; arg0 { - title = "Polyobj Number"; + title = "Polyobject Number"; + type = 25; } arg1 { @@ -486,11 +487,12 @@ zdoom } 86 { - title = "Polyobj Move to Spot"; + title = "Polyobject Move to Spot"; id = "Polyobj_MoveToSpot"; arg0 { - title = "Polyobj Number"; + title = "Polyobject Number"; + type = 25; } arg1 { @@ -508,20 +510,22 @@ zdoom } 87 { - title = "Polyobj Stop"; + title = "Polyobject Stop"; id = "Polyobj_Stop"; arg0 { - title = "Polyobj Number"; + title = "Polyobject Number"; + type = 25; } } 88 { - title = "Polyobj Move to"; + title = "Polyobject Move to"; id = "Polyobj_MoveTo"; arg0 { - title = "Polyobj Number"; + title = "Polyobject Number"; + type = 25; } arg1 { @@ -541,11 +545,12 @@ zdoom } 89 { - title = "Polyobj Move to (override)"; + title = "Polyobject Move to (override)"; id = "Polyobj_OR_MoveTo"; arg0 { - title = "Polyobj Number"; + title = "Polyobject Number"; + type = 25; } arg1 { @@ -4202,7 +4207,7 @@ hexen } polyobj { - 1 // Polyobj Start Line + 1 // Polyobject Start Line { arg3 { @@ -4210,7 +4215,7 @@ hexen type = 0; } } - 5 // Polyobj Explicit Line + 5 // Polyobject Explicit Line { arg4 { diff --git a/Help/gc_argumentsettings.html b/Help/gc_argumentsettings.html index f2611205..dfe188c6 100644 --- a/Help/gc_argumentsettings.html +++ b/Help/gc_argumentsettings.html @@ -47,8 +47,9 @@
  • 14 = Thing tag
  • 15 = Linedef tag
  • 22 = Byte angle (GZDB only)
  • -
  • 23 = Thing Radius (GZDB only)
  • -
  • 24 = Thing Height (GZDB only)
  • +
  • 23 = Thing radius (GZDB only)
  • +
  • 24 = Thing height (GZDB only)
  • +
  • 25 = Polyobject number (GZDB only)
  • targetclasses (string) - GZDB only
    When set, only things of given classes will be shown in the argument dropdown list. Used only when argument type is 14.
    diff --git a/Source/Core/Builder.csproj b/Source/Core/Builder.csproj index 439f09ff..130d974f 100644 --- a/Source/Core/Builder.csproj +++ b/Source/Core/Builder.csproj @@ -924,6 +924,7 @@ + diff --git a/Source/Core/Types/LinedefTagHandler.cs b/Source/Core/Types/LinedefTagHandler.cs index 989676ab..b9050b84 100644 --- a/Source/Core/Types/LinedefTagHandler.cs +++ b/Source/Core/Types/LinedefTagHandler.cs @@ -29,7 +29,7 @@ namespace CodeImp.DoomBuilder.Types { #region ================== Setup - protected override EnumList CreateTagList() + protected override EnumList CreateEnumList() { //collect tags List tags = new List(); diff --git a/Source/Core/Types/PolyobjectNumberHandler.cs b/Source/Core/Types/PolyobjectNumberHandler.cs new file mode 100644 index 00000000..5dc67ad4 --- /dev/null +++ b/Source/Core/Types/PolyobjectNumberHandler.cs @@ -0,0 +1,51 @@ +#region ================== Namespaces + +using System.Collections.Generic; +using CodeImp.DoomBuilder.Config; +using CodeImp.DoomBuilder.Map; + +#endregion + +namespace CodeImp.DoomBuilder.Types +{ + [TypeHandler(UniversalType.PolyobjectNumber, "Polyobject Number", false)] + internal class PolyobjectNumberHandler : SectorTagHandler + { + #region ================== Setup + + protected override EnumList CreateEnumList() + { + // Collect polyobjects + HashSet ponums = new HashSet(); + EnumList polist = new EnumList(); + + foreach(Thing t in General.Map.Map.Things) + { + ThingTypeInfo info = General.Map.Data.GetThingInfoEx(t.Type); + if(info == null || info.ClassName.ToLowerInvariant() != "$polyanchor") continue; + ponums.Add(t.AngleDoom); + } + + // Now sort them in descending order + List ponumslist = new List(ponums); + ponumslist.Sort((a, b) => -1 * a.CompareTo(b)); + + // Create enum items + foreach(int ponum in ponums) + polist.Add(new EnumItem(ponum.ToString(), ponum.ToString())); + + return polist; + } + + #endregion + + #region ================== Methods + + public override string GetStringValue() + { + return (this.value != null ? this.value.Title : "0: 0"); + } + + #endregion + } +} \ No newline at end of file diff --git a/Source/Core/Types/SectorTagHandler.cs b/Source/Core/Types/SectorTagHandler.cs index dcf1e2f8..577aaee9 100644 --- a/Source/Core/Types/SectorTagHandler.cs +++ b/Source/Core/Types/SectorTagHandler.cs @@ -32,7 +32,7 @@ namespace CodeImp.DoomBuilder.Types #region ================== Variables private EnumList list; - private EnumItem value; + protected EnumItem value; private EnumItem defaultvalue; #endregion @@ -52,7 +52,7 @@ namespace CodeImp.DoomBuilder.Types base.SetupArgument(attr, arginfo); // Create enum list reference - list = CreateTagList(); + list = CreateEnumList(); // Add default value list.Insert(0, defaultvalue); @@ -64,11 +64,11 @@ namespace CodeImp.DoomBuilder.Types base.SetupField(attr, fieldinfo); // Create enum list reference - list = CreateTagList(); + list = CreateEnumList(); } //mxd - protected virtual EnumList CreateTagList() + protected virtual EnumList CreateEnumList() { //collect tags List tags = new List(); diff --git a/Source/Core/Types/ThingTagHandler.cs b/Source/Core/Types/ThingTagHandler.cs index ccc34fa0..b5e814b4 100644 --- a/Source/Core/Types/ThingTagHandler.cs +++ b/Source/Core/Types/ThingTagHandler.cs @@ -29,7 +29,7 @@ namespace CodeImp.DoomBuilder.Types { #region ================== Setup - protected override EnumList CreateTagList() + protected override EnumList CreateEnumList() { // Collect tags List tags = new List(); diff --git a/Source/Core/Types/UniversalType.cs b/Source/Core/Types/UniversalType.cs index 65f82539..98481032 100644 --- a/Source/Core/Types/UniversalType.cs +++ b/Source/Core/Types/UniversalType.cs @@ -47,5 +47,6 @@ namespace CodeImp.DoomBuilder.Types AngleByte = 22, //mxd ThingRadius = 23, //mxd ThingHeight = 24, //mxd + PolyobjectNumber = 25, //mxd } } diff --git a/Source/Plugins/BuilderModes/ErrorChecks/CheckPolyobjects.cs b/Source/Plugins/BuilderModes/ErrorChecks/CheckPolyobjects.cs index a70153d7..c97d639e 100644 --- a/Source/Plugins/BuilderModes/ErrorChecks/CheckPolyobjects.cs +++ b/Source/Plugins/BuilderModes/ErrorChecks/CheckPolyobjects.cs @@ -37,6 +37,7 @@ namespace CodeImp.DoomBuilder.BuilderModes int progress = 0; int stepprogress = 0; const string Polyobj_StartLine = "Polyobj_StartLine"; + const string Polyobj_ExplicitLine = "Polyobj_ExplicitLine"; // > Dictionary>> polyobjlines = new Dictionary>>(); @@ -44,14 +45,15 @@ namespace CodeImp.DoomBuilder.BuilderModes // All polyobject-related actions HashSet allactions = new HashSet(StringComparer.OrdinalIgnoreCase) { - Polyobj_StartLine, "Polyobj_RotateLeft", - "Polyobj_RotateRight", "Polyobj_Move", - "Polyobj_MoveTimes8", "Polyobj_DoorSwing", - "Polyobj_DoorSlide", "Polyobj_OR_MoveToSpot", - "Polyobj_MoveToSpot", "Polyobj_Stop", - "Polyobj_MoveTo", "Polyobj_OR_MoveTo", - "Polyobj_OR_RotateLeft", "Polyobj_OR_RotateRight", - "Polyobj_OR_Move", "Polyobj_OR_MoveTimes8" + Polyobj_StartLine, Polyobj_ExplicitLine, + "Polyobj_RotateLeft", "Polyobj_RotateRight", + "Polyobj_Move", "Polyobj_MoveTimes8", + "Polyobj_DoorSwing", "Polyobj_DoorSlide", + "Polyobj_OR_MoveToSpot", "Polyobj_MoveToSpot", + "Polyobj_Stop", "Polyobj_MoveTo", + "Polyobj_OR_MoveTo", "Polyobj_OR_RotateLeft", + "Polyobj_OR_RotateRight", "Polyobj_OR_Move", + "Polyobj_OR_MoveTimes8", }; Dictionary> anchors = new Dictionary>(); @@ -136,6 +138,27 @@ namespace CodeImp.DoomBuilder.BuilderModes } } + // Check Linedefs with Polyobj_ExplicitLine action. These can connect 1 - multiple. + // Polyobject number is arg0, Mirror polyobject number is arg2 + if(polyobjlines.ContainsKey(Polyobj_ExplicitLine)) + { + foreach(KeyValuePair> linesbytype in polyobjlines[Polyobj_ExplicitLine]) + { + // Check if Mirror Polyobject Number exists + foreach(Linedef linedef in linesbytype.Value) + { + // The value of 0 can mean either "No mirror polyobj" or "Polyobj 0" here... + if(linedef.Args[2] > 0) + { + if(!startspots.ContainsKey(linedef.Args[2])) + SubmitResult(new ResultInvalidPolyobjectLines(new List { linedef }, "\"" + Polyobj_StartLine + "\" action have non-existing Mirror Polyobject Number assigned (" + linedef.Args[2] + "). It won't function correctly ingame.")); + if(linedef.Args[2] == linedef.Args[0]) + SubmitResult(new ResultInvalidPolyobjectLines(new List { linedef }, "\"" + Polyobj_StartLine + "\" action have the same Polyobject and Mirror Polyobject numbers assigned (" + linedef.Args[2] + "). It won't function correctly ingame.")); + } + } + } + } + // Check Polyobject Anchors. These must connect 1 - 1. foreach(KeyValuePair> group in anchors) {