From 9147c31234061404ceecd3691bb9e60c37b4a212 Mon Sep 17 00:00:00 2001
From: MaxED <j.maxed@gmail.com>
Date: Wed, 22 Jun 2016 14:27:37 +0000
Subject: [PATCH] Fixed: in some cases incorrect Script Configuration was used
 to compile scripts when performing "Save Map" / "Test Map" actions.

---
 Source/Core/Config/MapLumpInfo.cs | 2 +-
 Source/Core/General/MapManager.cs | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Source/Core/Config/MapLumpInfo.cs b/Source/Core/Config/MapLumpInfo.cs
index 76e168b95..4865b221b 100644
--- a/Source/Core/Config/MapLumpInfo.cs
+++ b/Source/Core/Config/MapLumpInfo.cs
@@ -44,7 +44,7 @@ namespace CodeImp.DoomBuilder.Config
 			this.NodeBuild = cfg.ReadSetting("maplumpnames." + name + ".nodebuild", false);
 			this.AllowEmpty = cfg.ReadSetting("maplumpnames." + name + ".allowempty", false);
 			this.ScriptBuild = cfg.ReadSetting("maplumpnames." + name + ".scriptbuild", false); //mxd
-			string scriptconfig = cfg.ReadSetting("maplumpnames." + name + ".script", "");
+			string scriptconfig = (this.ScriptBuild ? string.Empty : cfg.ReadSetting("maplumpnames." + name + ".script", "")); //mxd. Setting Script when "scriptbuild" is true can result in unexpected behaviour...
 			
 			// Find script configuration
 			if(scriptconfig.Length > 0)
diff --git a/Source/Core/General/MapManager.cs b/Source/Core/General/MapManager.cs
index cabdfc05b..0f083b3f3 100644
--- a/Source/Core/General/MapManager.cs
+++ b/Source/Core/General/MapManager.cs
@@ -753,9 +753,9 @@ namespace CodeImp.DoomBuilder
 			// If the scripts window is open, save the scripts first
 			if(IsScriptsWindowOpen) scriptwindow.Editor.ImplicitSave();
 
-			// Only recompile scripts when the scripts have changed
+			// Only recompile scripts when the scripts have changed or there are compiler errors (mxd)
 			// (not when only the map changed)
-			if(localscriptschanged && !CompileScriptLumps()) 
+			if((localscriptschanged || errors.Count > 0) && !CompileScriptLumps()) 
 			{
 				// Compiler failure
 				if(errors.Count > 0)
-- 
GitLab