diff --git a/Source/Builder.csproj b/Source/Builder.csproj
index d60c9b38..06bf896b 100644
--- a/Source/Builder.csproj
+++ b/Source/Builder.csproj
@@ -291,6 +291,7 @@
+
diff --git a/Source/BuilderModes/ClassicModes/DragGeometryMode.cs b/Source/BuilderModes/ClassicModes/DragGeometryMode.cs
index db85aefb..4dfc3690 100644
--- a/Source/BuilderModes/ClassicModes/DragGeometryMode.cs
+++ b/Source/BuilderModes/ClassicModes/DragGeometryMode.cs
@@ -301,6 +301,9 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
// Stitch geometry
if(snaptonearest) General.Map.Map.StitchGeometry();
+ // Snap to map format accuracy
+ General.Map.Map.SnapAllToAccuracy();
+
// Update cached values
General.Map.Map.Update();
diff --git a/Source/BuilderModes/ClassicModes/DrawGeometryMode.cs b/Source/BuilderModes/ClassicModes/DrawGeometryMode.cs
index f28a4f0b..dddb1762 100644
--- a/Source/BuilderModes/ClassicModes/DrawGeometryMode.cs
+++ b/Source/BuilderModes/ClassicModes/DrawGeometryMode.cs
@@ -332,6 +332,9 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
// Make corrections for backward linedefs
MapSet.FlipBackwardLinedefs(newlines);
+
+ // Snap to map format accuracy
+ General.Map.Map.SnapAllToAccuracy();
// Update cached values
map.Update();
diff --git a/Source/General/MapManager.cs b/Source/General/MapManager.cs
index 33182075..f2e16576 100644
--- a/Source/General/MapManager.cs
+++ b/Source/General/MapManager.cs
@@ -103,7 +103,7 @@ namespace CodeImp.DoomBuilder
public GameConfiguration Config { get { return config; } }
public GridSetup Grid { get { return grid; } }
public UndoManager UndoRedo { get { return undoredo; } }
- public Type Type { get { return io.GetType(); } }
+ public IMapSetIO FormatInterface { get { return io; } }
#endregion
diff --git a/Source/IO/DoomMapSetIO.cs b/Source/IO/DoomMapSetIO.cs
index 3e14c244..9f52b040 100644
--- a/Source/IO/DoomMapSetIO.cs
+++ b/Source/IO/DoomMapSetIO.cs
@@ -47,6 +47,7 @@ namespace CodeImp.DoomBuilder.IO
#region ================== Properties
public override int MaxSidedefs { get { return 65534; } }
+ public override int VertexDecimals { get { return 0; } }
#endregion
diff --git a/Source/IO/HexenMapSetIO.cs b/Source/IO/HexenMapSetIO.cs
index 49822742..e61e5b52 100644
--- a/Source/IO/HexenMapSetIO.cs
+++ b/Source/IO/HexenMapSetIO.cs
@@ -47,6 +47,7 @@ namespace CodeImp.DoomBuilder.IO
#region ================== Properties
public override int MaxSidedefs { get { return 65534; } }
+ public override int VertexDecimals { get { return 0; } }
#endregion
diff --git a/Source/IO/IMapSetIO.cs b/Source/IO/IMapSetIO.cs
new file mode 100644
index 00000000..4fd76db8
--- /dev/null
+++ b/Source/IO/IMapSetIO.cs
@@ -0,0 +1,38 @@
+
+#region ================== Copyright (c) 2007 Pascal vd Heiden
+
+/*
+ * Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
+ * This program is released under GNU General Public License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#endregion
+
+#region ================== Namespaces
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Text;
+using System.IO;
+using CodeImp.DoomBuilder.Map;
+using System.Reflection;
+using System.Diagnostics;
+
+#endregion
+
+namespace CodeImp.DoomBuilder.IO
+{
+ public interface IMapSetIO
+ {
+ int MaxSidedefs { get; }
+ int VertexDecimals { get; }
+ }
+}
diff --git a/Source/IO/MapSetIO.cs b/Source/IO/MapSetIO.cs
index b03238b6..789516ce 100644
--- a/Source/IO/MapSetIO.cs
+++ b/Source/IO/MapSetIO.cs
@@ -30,7 +30,7 @@ using System.Diagnostics;
namespace CodeImp.DoomBuilder.IO
{
- internal abstract class MapSetIO
+ internal abstract class MapSetIO : IMapSetIO
{
#region ================== Constants
@@ -49,13 +49,14 @@ namespace CodeImp.DoomBuilder.IO
#region ================== Properties
public abstract int MaxSidedefs { get; }
+ public abstract int VertexDecimals { get; }
#endregion
#region ================== Constructor / Disposer
// Constructor
- public MapSetIO(WAD wad, MapManager manager)
+ internal MapSetIO(WAD wad, MapManager manager)
{
// Initialize
this.wad = wad;
diff --git a/Source/IO/UniversalMapSetIO.cs b/Source/IO/UniversalMapSetIO.cs
index 72f3493d..7aec3a99 100644
--- a/Source/IO/UniversalMapSetIO.cs
+++ b/Source/IO/UniversalMapSetIO.cs
@@ -48,6 +48,7 @@ namespace CodeImp.DoomBuilder.IO
#region ================== Properties
public override int MaxSidedefs { get { return int.MaxValue; } }
+ public override int VertexDecimals { get { return 3; } }
#endregion
diff --git a/Source/Map/MapSet.cs b/Source/Map/MapSet.cs
index 37be2cc8..b4c1e2a3 100644
--- a/Source/Map/MapSet.cs
+++ b/Source/Map/MapSet.cs
@@ -1205,6 +1205,12 @@ namespace CodeImp.DoomBuilder.Map
#region ================== Tools
+ // This snaps all vertices to the map format accuracy
+ public void SnapAllToAccuracy()
+ {
+ foreach(Vertex v in vertices) v.SnapToAccuracy();
+ }
+
// This returns the next unused tag number
public int GetNewTag()
{
diff --git a/Source/Map/Vertex.cs b/Source/Map/Vertex.cs
index 26c0aa3b..b9d1702a 100644
--- a/Source/Map/Vertex.cs
+++ b/Source/Map/Vertex.cs
@@ -194,19 +194,21 @@ namespace CodeImp.DoomBuilder.Map
public void Move(Vector2D newpos)
{
// Change position
- this.Move((int)Math.Round(newpos.x), (int)Math.Round(newpos.y));
- }
-
- // This moves the vertex
- public void Move(int newx, int newy)
- {
- // Change position
- pos = new Vector2D(newx, newy);
+ pos = newpos;
// Let all lines know they need an update
foreach(Linedef l in linedefs) l.NeedUpdate();
}
+ // This snaps the vertex to the map format accuracy
+ public void SnapToAccuracy()
+ {
+ // Round the coordinates
+ Vector2D newpos = new Vector2D((float)Math.Round(pos.x, General.Map.FormatInterface.VertexDecimals),
+ (float)Math.Round(pos.y, General.Map.FormatInterface.VertexDecimals));
+ this.Move(newpos);
+ }
+
// This snaps the vertex to the grid
public void SnapToGrid()
{