diff --git a/Source/Core/Geometry/Tools.cs b/Source/Core/Geometry/Tools.cs index 4d38d46aa4219ff51bae6f70f9c7a609984bf00c..edca7fded318d95c87515c031193ec9d00188ab4 100755 --- a/Source/Core/Geometry/Tools.cs +++ b/Source/Core/Geometry/Tools.cs @@ -1687,7 +1687,7 @@ namespace CodeImp.DoomBuilder.Geometry if(l.Front.MiddleRequired() && l.Front.LongMiddleTexture != MapSet.EmptyLongName && General.Map.Data.GetTextureExists(l.Front.LongMiddleTexture)) { ImageData texture = General.Map.Data.GetTextureImage(l.Front.LongMiddleTexture); - float offset = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength)); + double offset = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength)); if(texture.IsImageLoaded) offset %= texture.Width; if(offset > 0) UniFields.SetFloat(l.Front.Fields, "offsetx_mid", offset); } @@ -1695,7 +1695,7 @@ namespace CodeImp.DoomBuilder.Geometry if(l.Front.HighRequired() && l.Front.LongHighTexture != MapSet.EmptyLongName && General.Map.Data.GetTextureExists(l.Front.LongHighTexture)) { ImageData texture = General.Map.Data.GetTextureImage(l.Front.LongHighTexture); - float offset = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength)); + double offset = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength)); if(texture.IsImageLoaded) offset %= texture.Width; if(offset > 0) UniFields.SetFloat(l.Front.Fields, "offsetx_top", offset); } @@ -1703,7 +1703,7 @@ namespace CodeImp.DoomBuilder.Geometry if(l.Front.LowRequired() && l.Front.LongLowTexture != MapSet.EmptyLongName && General.Map.Data.GetTextureExists(l.Front.LongLowTexture)) { ImageData texture = General.Map.Data.GetTextureImage(l.Front.LongLowTexture); - float offset = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength)); + double offset = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength)); if(texture.IsImageLoaded) offset %= texture.Width; if(offset > 0) UniFields.SetFloat(l.Front.Fields, "offsetx_bottom", offset); } @@ -1714,7 +1714,7 @@ namespace CodeImp.DoomBuilder.Geometry if(l.Back.MiddleRequired() && l.Back.LongMiddleTexture != MapSet.EmptyLongName && General.Map.Data.GetTextureExists(l.Back.LongMiddleTexture)) { ImageData texture = General.Map.Data.GetTextureImage(l.Back.LongMiddleTexture); - float offset = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength)); + double offset = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength)); if(texture.IsImageLoaded) offset %= texture.Width; if(offset > 0) UniFields.SetFloat(l.Back.Fields, "offsetx_mid", offset); } @@ -1722,7 +1722,7 @@ namespace CodeImp.DoomBuilder.Geometry if(l.Back.HighRequired() && l.Back.LongHighTexture != MapSet.EmptyLongName && General.Map.Data.GetTextureExists(l.Back.LongHighTexture)) { ImageData texture = General.Map.Data.GetTextureImage(l.Back.LongHighTexture); - float offset = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength)); + double offset = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength)); if(texture.IsImageLoaded) offset %= texture.Width; if(offset > 0) UniFields.SetFloat(l.Back.Fields, "offsetx_top", offset); } @@ -1730,7 +1730,7 @@ namespace CodeImp.DoomBuilder.Geometry if(l.Back.LowRequired() && l.Back.LongLowTexture != MapSet.EmptyLongName && General.Map.Data.GetTextureExists(l.Back.LongLowTexture)) { ImageData texture = General.Map.Data.GetTextureImage(l.Back.LongLowTexture); - float offset = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength)); + double offset = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength)); if(texture.IsImageLoaded) offset %= texture.Width; if(offset > 0) UniFields.SetFloat(l.Back.Fields, "offsetx_bottom", offset); } diff --git a/Source/Core/IO/ClipboardStreamWriter.cs b/Source/Core/IO/ClipboardStreamWriter.cs index 93c4b0654b94883a51ef0d6020455d63ef7d11e2..2ac34c7e41bed2fd876a425338357b3bf22fe6c9 100755 --- a/Source/Core/IO/ClipboardStreamWriter.cs +++ b/Source/Core/IO/ClipboardStreamWriter.cs @@ -279,12 +279,12 @@ namespace CodeImp.DoomBuilder.IO { writer.Write((int)UniversalType.Boolean); writer.Write((bool)f.Value.Value); - } + }/* else if(f.Value.Value is float) { writer.Write((int)UniversalType.Float); writer.Write((float)f.Value.Value); - } + }*/ else if(f.Value.Value is double) { writer.Write((int)UniversalType.Float); diff --git a/Source/Core/Map/Sector.cs b/Source/Core/Map/Sector.cs index 87a18c8ce61a6d3006df973118dc01e64c4e116e..8047f5d64f432f63b74d86b28ae45b27426cbc42 100755 --- a/Source/Core/Map/Sector.cs +++ b/Source/Core/Map/Sector.cs @@ -128,12 +128,12 @@ namespace CodeImp.DoomBuilder.Map //mxd. Rednering public Color4 FogColor { get { return fogcolor; } } public SectorFogMode FogMode { get { return fogmode; } } - public float Desaturation + public double Desaturation { get { if (General.Map.UDMF && Fields.ContainsKey("desaturation")) - return (float)Fields["desaturation"].Value; + return (double)Fields["desaturation"].Value; return 0f; } } diff --git a/Source/Core/Map/UniFields.cs b/Source/Core/Map/UniFields.cs index b57daed0b38562449f773f2b0cdf0f177f667eef..2790e9358d5bfb8f71220134bee53305a2e84e4f 100755 --- a/Source/Core/Map/UniFields.cs +++ b/Source/Core/Map/UniFields.cs @@ -226,6 +226,7 @@ namespace CodeImp.DoomBuilder.Map if(val1.Type != val2.Type) return false; if(val1.Value is int) return (int)val1.Value == (int)val2.Value; if(val1.Value is float) return (float)val1.Value == (float)val2.Value; + if(val1.Value is double) return (double)val1.Value == (double)val2.Value; if(val1.Value is bool) return (bool)val1.Value == (bool)val2.Value; if(val1.Value is string) return (string)val1.Value == (string)val2.Value; throw new NotImplementedException("Unknown Custom Field type: " + val1.Value.GetType()); diff --git a/Source/Core/Map/UniValue.cs b/Source/Core/Map/UniValue.cs index d1b81b4f9cba2ed64ca4e1e9c8d2d2c281f56c1b..134e57d074a9894c7af4f2a999d67d00f51e78de 100755 --- a/Source/Core/Map/UniValue.cs +++ b/Source/Core/Map/UniValue.cs @@ -68,6 +68,10 @@ namespace CodeImp.DoomBuilder.Map // Constructor public UniValue(int type, object value) { + // Value may only be a primitive type. Throwing exceptions in the constructor! Civil war! + if ((!(value is int) && !(value is double) && !(value is string) && !(value is bool)) || (value == null)) + throw new ArgumentException("Universal field values can only be of type int, double, string or bool."); + this.type = type; this.value = value; @@ -78,6 +82,10 @@ namespace CodeImp.DoomBuilder.Map // Constructor public UniValue(UniversalType type, object value) { + // Value may only be a primitive type. Throwing exceptions in the constructor! Civil war! + if ((!(value is int) && !(value is double) && !(value is string) && !(value is bool)) || (value == null)) + throw new ArgumentException("Universal field values can only be of type int, double, string or bool."); + this.type = (int)type; this.value = value; diff --git a/Source/Core/Rendering/Renderer3D.cs b/Source/Core/Rendering/Renderer3D.cs index 37abebe1a2617b94eb6c21153c910a0f37ed8265..c54c28c1113b4f7f331937fb27924764162d74be 100755 --- a/Source/Core/Rendering/Renderer3D.cs +++ b/Source/Core/Rendering/Renderer3D.cs @@ -897,7 +897,7 @@ namespace CodeImp.DoomBuilder.Rendering graphics.SetUniform(UniformName.highlightcolor, CalculateHighlightColor((g == highlighted) && showhighlight, (g.Selected && showselection))); // [ZZ] include desaturation factor - graphics.SetUniform(UniformName.desaturation, sector.Sector.Desaturation); + graphics.SetUniform(UniformName.desaturation, (float)sector.Sector.Desaturation); // Render! graphics.Draw(PrimitiveType.TriangleList, g.VertexOffset, g.Triangles); @@ -994,7 +994,7 @@ namespace CodeImp.DoomBuilder.Rendering // [ZZ] apply desaturation if (t.Thing.Sector != null) - graphics.SetUniform(UniformName.desaturation, t.Thing.Sector.Desaturation); + graphics.SetUniform(UniformName.desaturation, (float)t.Thing.Sector.Desaturation); else graphics.SetUniform(UniformName.desaturation, 0.0f); // Apply changes @@ -1204,7 +1204,7 @@ namespace CodeImp.DoomBuilder.Rendering } // - graphics.SetUniform(UniformName.desaturation, sector.Sector.Desaturation); + graphics.SetUniform(UniformName.desaturation, (float)sector.Sector.Desaturation); // Set the colors to use graphics.SetUniform(UniformName.sectorfogcolor, sector.Sector.FogColor); @@ -1340,7 +1340,7 @@ namespace CodeImp.DoomBuilder.Rendering graphics.SetUniform(UniformName.stencilColor, t.StencilColor.ToColorValue()); // - graphics.SetUniform(UniformName.desaturation, t.Thing.Sector.Desaturation); + graphics.SetUniform(UniformName.desaturation, (float)t.Thing.Sector.Desaturation); // Apply changes graphics.SetUniform(UniformName.world, world); @@ -1514,7 +1514,7 @@ namespace CodeImp.DoomBuilder.Rendering } if (t.Thing.Sector != null) - graphics.SetUniform(UniformName.desaturation, t.Thing.Sector.Desaturation); + graphics.SetUniform(UniformName.desaturation, (float)t.Thing.Sector.Desaturation); else graphics.SetUniform(UniformName.desaturation, 0.0f); int lightIndex = 0; diff --git a/Source/Core/Rendering/SurfaceEntry.cs b/Source/Core/Rendering/SurfaceEntry.cs index 3b58acd4e9be1f5374b4dcfb0710227e03899dd2..add84fe2869270e4c8037be8b33bc3b4b3c8cbfb 100755 --- a/Source/Core/Rendering/SurfaceEntry.cs +++ b/Source/Core/Rendering/SurfaceEntry.cs @@ -50,7 +50,7 @@ namespace CodeImp.DoomBuilder.Rendering public long ceiltexture; // - public float desaturation; + public double desaturation; // Constructor internal SurfaceEntry(int numvertices, int bufferindex, int vertexoffset) diff --git a/Source/Core/Rendering/SurfaceManager.cs b/Source/Core/Rendering/SurfaceManager.cs index 7c5a3b7ed0a91a9e3b356f592d0c6c4657add683..5fbec73b2e8435341fef040ce8c85fb94e94c248 100755 --- a/Source/Core/Rendering/SurfaceManager.cs +++ b/Source/Core/Rendering/SurfaceManager.cs @@ -616,7 +616,7 @@ namespace CodeImp.DoomBuilder.Rendering VertexBuffer lastbuffer = null; foreach(SurfaceEntry entry in imgsurfaces.Value) { - graphics.SetUniform(UniformName.desaturation, entry.desaturation); + graphics.SetUniform(UniformName.desaturation, (float)entry.desaturation); // Set the vertex buffer SurfaceBufferSet set = sets[entry.numvertices]; diff --git a/Source/Core/Rendering/SurfaceUpdate.cs b/Source/Core/Rendering/SurfaceUpdate.cs index 30a52a188c062b5f2926211e69fcfbeb32083783..969f8bc89f59ea6bc9bc003d450cc24d138a3537 100755 --- a/Source/Core/Rendering/SurfaceUpdate.cs +++ b/Source/Core/Rendering/SurfaceUpdate.cs @@ -37,7 +37,7 @@ namespace CodeImp.DoomBuilder.Rendering public long ceiltexture; // - public float desaturation; + public double desaturation; // Constructor internal SurfaceUpdate(int numvertices, bool updatefloor, bool updateceiling) diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualLower.cs b/Source/Plugins/BuilderModes/VisualModes/VisualLower.cs index ebfa8a3249e20d0a1cbca4564a7aeaaf387bfcbb..9bb8659026286a846abd77501bf83a86bd088b15 100755 --- a/Source/Plugins/BuilderModes/VisualModes/VisualLower.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualLower.cs @@ -258,13 +258,13 @@ namespace CodeImp.DoomBuilder.BuilderModes protected override void SetTextureOffsetX(int x) { Sidedef.Fields.BeforeFieldsChange(); - Sidedef.Fields["offsetx_bottom"] = new UniValue(UniversalType.Float, (float)x); + Sidedef.Fields["offsetx_bottom"] = new UniValue(UniversalType.Float, (double)x); } protected override void SetTextureOffsetY(int y) { Sidedef.Fields.BeforeFieldsChange(); - Sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, (float)y); + Sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, (double)y); } protected override void MoveTextureOffset(int offsetx, int offsety)