From 0787f96042b87a95ebfe5aa90c5dc7f13db8947a Mon Sep 17 00:00:00 2001
From: ZZYZX <zzyzx@virtual>
Date: Tue, 17 Jan 2017 06:53:20 +0200
Subject: [PATCH] GLDEFS, MODELDEF: Included ZScript actors in missing class
 check

---
 Source/Core/Data/DataManager.cs                        | 4 ++--
 Source/Core/Properties/AssemblyInfo.cs                 | 4 ++--
 Source/Core/ZDoom/DecorateActorStructure.cs            | 4 ++--
 Source/Core/ZDoom/DecorateParser.cs                    | 2 +-
 Source/Core/ZDoom/DecorateStateStructure.cs            | 2 +-
 Source/Core/ZDoom/GldefsParser.cs                      | 2 +-
 Source/Core/ZDoom/ModeldefParser.cs                    | 2 +-
 Source/Core/ZDoom/StateStructure.cs                    | 9 +++------
 Source/Core/ZDoom/ZDTextParser.cs                      | 8 +-------
 Source/Core/ZDoom/ZScriptActorStructure.cs             | 2 +-
 Source/Core/ZDoom/ZScriptParser.cs                     | 2 +-
 Source/Core/ZDoom/ZScriptStateStructure.cs             | 2 +-
 Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs | 2 +-
 13 files changed, 18 insertions(+), 27 deletions(-)

diff --git a/Source/Core/Data/DataManager.cs b/Source/Core/Data/DataManager.cs
index 835eb07e7..683904330 100755
--- a/Source/Core/Data/DataManager.cs
+++ b/Source/Core/Data/DataManager.cs
@@ -1827,7 +1827,7 @@ namespace CodeImp.DoomBuilder.Data
         private void LoadZScriptThings()
         {
             // Create new parser
-            zscript = new ZScriptParser(this) { OnInclude = LoadZScriptFromLocation };
+            zscript = new ZScriptParser { OnInclude = LoadZScriptFromLocation };
 
             // Only load these when the game configuration supports the use of decorate
             if (!string.IsNullOrEmpty(General.Map.Config.DecorateGames))
@@ -1871,7 +1871,7 @@ namespace CodeImp.DoomBuilder.Data
 		private void LoadDecorateThings()
 		{
 			// Create new parser
-			decorate = new DecorateParser(this, zscript.AllActorsByClass) { OnInclude = LoadDecorateFromLocation };
+			decorate = new DecorateParser(zscript.AllActorsByClass) { OnInclude = LoadDecorateFromLocation };
 
 			// Only load these when the game configuration supports the use of decorate
 			if(!string.IsNullOrEmpty(General.Map.Config.DecorateGames))
diff --git a/Source/Core/Properties/AssemblyInfo.cs b/Source/Core/Properties/AssemblyInfo.cs
index 7bc25e8f7..b4f6c608c 100755
--- a/Source/Core/Properties/AssemblyInfo.cs
+++ b/Source/Core/Properties/AssemblyInfo.cs
@@ -30,6 +30,6 @@ using CodeImp.DoomBuilder;
 //      Build Number
 //      Revision
 //
-[assembly: AssemblyVersion("2.3.0.2823")]
+[assembly: AssemblyVersion("2.3.0.2824")]
 [assembly: NeutralResourcesLanguageAttribute("en")]
-[assembly: AssemblyHash("76213ae")]
+[assembly: AssemblyHash("3bdfadc")]
diff --git a/Source/Core/ZDoom/DecorateActorStructure.cs b/Source/Core/ZDoom/DecorateActorStructure.cs
index 99a93ae00..db46f372b 100755
--- a/Source/Core/ZDoom/DecorateActorStructure.cs
+++ b/Source/Core/ZDoom/DecorateActorStructure.cs
@@ -190,7 +190,7 @@ namespace CodeImp.DoomBuilder.ZDoom
                                     if (!string.IsNullOrEmpty(previoustoken))
                                     {
                                         // Parse actor state
-                                        StateStructure st = new DecorateStateStructure(this, parser, parser.DataManager);
+                                        StateStructure st = new DecorateStateStructure(this, parser);
                                         if (parser.HasError) return;
                                         states[previoustoken.ToLowerInvariant()] = st;
                                     }
@@ -403,7 +403,7 @@ namespace CodeImp.DoomBuilder.ZDoom
                     {
                         //states
                         if (states.Count == 0 && !string.IsNullOrEmpty(ti.Value.Sprite))
-                            states.Add("spawn", new StateStructure(ti.Value.Sprite.Substring(0, 5), parser.DataManager));
+                            states.Add("spawn", new StateStructure(ti.Value.Sprite.Substring(0, 5)));
 
                         //flags
                         if (ti.Value.Hangs && !flags.ContainsKey("spawnceiling"))
diff --git a/Source/Core/ZDoom/DecorateParser.cs b/Source/Core/ZDoom/DecorateParser.cs
index 7e76f5862..8cf0349b4 100755
--- a/Source/Core/ZDoom/DecorateParser.cs
+++ b/Source/Core/ZDoom/DecorateParser.cs
@@ -98,7 +98,7 @@ namespace CodeImp.DoomBuilder.ZDoom
 		#region ================== Constructor / Disposer
 		
 		// Constructor
-		public DecorateParser(DataManager dataman, Dictionary<string, ActorStructure> _zscriptactors) : base(dataman)
+		public DecorateParser(Dictionary<string, ActorStructure> _zscriptactors)
 		{
 			// Syntax
 			whitespace = "\n \t\r\u00A0"; //mxd. non-breaking space is also space :)
diff --git a/Source/Core/ZDoom/DecorateStateStructure.cs b/Source/Core/ZDoom/DecorateStateStructure.cs
index 79899ab4e..eeffafe53 100755
--- a/Source/Core/ZDoom/DecorateStateStructure.cs
+++ b/Source/Core/ZDoom/DecorateStateStructure.cs
@@ -15,7 +15,7 @@ namespace CodeImp.DoomBuilder.ZDoom
     {
         #region ================== DECORATE State Structure parsing
 
-        internal DecorateStateStructure(ActorStructure actor, ZDTextParser zdparser, DataManager dataman) : base(actor, zdparser, dataman)
+        internal DecorateStateStructure(ActorStructure actor, ZDTextParser zdparser) : base(actor, zdparser)
         {
             DecorateParser parser = (DecorateParser)zdparser;
             string lasttoken = "";
diff --git a/Source/Core/ZDoom/GldefsParser.cs b/Source/Core/ZDoom/GldefsParser.cs
index 895a899d6..99e3dc6a2 100755
--- a/Source/Core/ZDoom/GldefsParser.cs
+++ b/Source/Core/ZDoom/GldefsParser.cs
@@ -499,7 +499,7 @@ namespace CodeImp.DoomBuilder.ZDoom
 			}
 
 			// Check if actor exists
-			if(!General.Map.Data.Decorate.ActorsByClass.ContainsKey(objectclass))
+			if(General.Map.Data.GetZDoomActor(objectclass) == null)
 				LogWarning("DECORATE class \"" + objectclass + "\" does not exist");
 
 			// Now find opening brace
diff --git a/Source/Core/ZDoom/ModeldefParser.cs b/Source/Core/ZDoom/ModeldefParser.cs
index ba868bfc0..376c07837 100755
--- a/Source/Core/ZDoom/ModeldefParser.cs
+++ b/Source/Core/ZDoom/ModeldefParser.cs
@@ -70,7 +70,7 @@ namespace CodeImp.DoomBuilder.ZDoom
 
 				// Check if actor exists
 				bool haveplaceableactor = actorsbyclass.ContainsKey(classname);
-				if(!haveplaceableactor && !General.Map.Data.Decorate.ActorsByClass.ContainsKey(classname))
+				if(!haveplaceableactor && (General.Map.Data.GetZDoomActor(classname) == null))
 					LogWarning("DECORATE class \"" + classname + "\" does not exist");
 				
 				// Now find opening brace
diff --git a/Source/Core/ZDoom/StateStructure.cs b/Source/Core/ZDoom/StateStructure.cs
index 4dcdf0720..c43a3b905 100755
--- a/Source/Core/ZDoom/StateStructure.cs
+++ b/Source/Core/ZDoom/StateStructure.cs
@@ -42,7 +42,6 @@ namespace CodeImp.DoomBuilder.ZDoom
 		// All we care about is the first sprite in the sequence
 		internal List<FrameInfo> sprites;
 		internal StateGoto gotostate;
-        internal DataManager dataman;
 		
 		#endregion
 
@@ -55,18 +54,16 @@ namespace CodeImp.DoomBuilder.ZDoom
 		#region ================== Constructor / Disposer
 
 		// Constructor
-		internal StateStructure(ActorStructure actor, ZDTextParser parser, DataManager dataman)
+		internal StateStructure(ActorStructure actor, ZDTextParser parser)
 		{
 			this.gotostate = null;
-            this.dataman = dataman;
 			this.sprites = new List<FrameInfo>();
 		}
 
 		//mxd
-		internal StateStructure(string spritename, DataManager dataman) 
+		internal StateStructure(string spritename) 
 		{
 			this.gotostate = null;
-            this.dataman = dataman;
 			this.sprites = new List<FrameInfo> { new FrameInfo { Sprite = spritename } };
 		}
 
@@ -90,7 +87,7 @@ namespace CodeImp.DoomBuilder.ZDoom
 			if(gotostate != null)
 			{
 				// Find the class
-				ActorStructure a = dataman.GetZDoomActor(gotostate.ClassName);
+				ActorStructure a = General.Map.Data.GetZDoomActor(gotostate.ClassName);
 				if(a != null)
 				{
 					StateStructure s = a.GetState(gotostate.StateName);
diff --git a/Source/Core/ZDoom/ZDTextParser.cs b/Source/Core/ZDoom/ZDTextParser.cs
index b89b1559d..31089ed2f 100755
--- a/Source/Core/ZDoom/ZDTextParser.cs
+++ b/Source/Core/ZDoom/ZDTextParser.cs
@@ -68,10 +68,6 @@ namespace CodeImp.DoomBuilder.ZDoom
 		protected string textresourcepath;
 		protected readonly Dictionary<string, ScriptResource> scriptresources;
 		protected readonly HashSet<string> untrackedtextresources;
-
-        // [ZZ] this is required so that ActorStructure can query all other actor structures (i.e. decorate -> zscript)
-        private DataManager dataman;
-		
 		#endregion
 		
 		#region ================== Properties
@@ -84,17 +80,15 @@ namespace CodeImp.DoomBuilder.ZDoom
 		public bool HasError { get { return (errordesc != null); } }
 		internal abstract ScriptType ScriptType { get; } //mxd
 		internal Dictionary<string, ScriptResource> ScriptResources { get { return scriptresources; } } //mxd
-        internal DataManager DataManager { get { return dataman; } }
 
 		#endregion
 		
 		#region ================== Constructor / Disposer
 		
 		// Constructor
-		protected ZDTextParser(DataManager dataman = null)
+		protected ZDTextParser()
 		{
             // Initialize
-            this.dataman = dataman;
 			errordesc = null;
 			scriptresources = new Dictionary<string, ScriptResource>(StringComparer.OrdinalIgnoreCase); //mxd
 			untrackedtextresources = new HashSet<string>(StringComparer.OrdinalIgnoreCase); //mxd
diff --git a/Source/Core/ZDoom/ZScriptActorStructure.cs b/Source/Core/ZDoom/ZScriptActorStructure.cs
index 7c927c9d8..4b205c4ac 100755
--- a/Source/Core/ZDoom/ZScriptActorStructure.cs
+++ b/Source/Core/ZDoom/ZScriptActorStructure.cs
@@ -146,7 +146,7 @@ namespace CodeImp.DoomBuilder.ZDoom
             {
                 // parse a state block.
                 // this is a seriously broken approach, but let it be for now.
-                StateStructure st = new ZScriptStateStructure(this, parser, parser.DataManager);
+                StateStructure st = new ZScriptStateStructure(this, parser);
                 parser.tokenizer = tokenizer;
                 if (parser.HasError) return false;
                 states[statelabel] = st;
diff --git a/Source/Core/ZDoom/ZScriptParser.cs b/Source/Core/ZDoom/ZScriptParser.cs
index 695abc1f9..3eb88e89b 100755
--- a/Source/Core/ZDoom/ZScriptParser.cs
+++ b/Source/Core/ZDoom/ZScriptParser.cs
@@ -188,7 +188,7 @@ namespace CodeImp.DoomBuilder.ZDoom
         #region ================== Constructor / Disposer
 
         // Constructor
-        public ZScriptParser(DataManager dataman) : base(dataman)
+        public ZScriptParser()
         {
             ClearActors();
         }
diff --git a/Source/Core/ZDoom/ZScriptStateStructure.cs b/Source/Core/ZDoom/ZScriptStateStructure.cs
index 2cdd466e1..fbd269269 100755
--- a/Source/Core/ZDoom/ZScriptStateStructure.cs
+++ b/Source/Core/ZDoom/ZScriptStateStructure.cs
@@ -48,7 +48,7 @@ namespace CodeImp.DoomBuilder.ZDoom
             return null;
         }
 
-        internal ZScriptStateStructure(ActorStructure actor, ZDTextParser zdparser, DataManager dataman) : base(actor, zdparser, dataman)
+        internal ZScriptStateStructure(ActorStructure actor, ZDTextParser zdparser) : base(actor, zdparser)
         {
             ZScriptParser parser = (ZScriptParser)zdparser;
             Stream stream = parser.DataStream;
diff --git a/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs b/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs
index cc9f780c2..063d478d0 100755
--- a/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs
+++ b/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@ using System.Resources;
 //      Build Number
 //      Revision
 //
-[assembly: AssemblyVersion("2.3.0.2823")]
+[assembly: AssemblyVersion("2.3.0.2824")]
 [assembly: NeutralResourcesLanguageAttribute("en")]
-- 
GitLab