diff --git a/MCGalaxy/Commands/Information/CmdMapInfo.cs b/MCGalaxy/Commands/Information/CmdMapInfo.cs
index 0964c38d6..6613f9d6b 100644
--- a/MCGalaxy/Commands/Information/CmdMapInfo.cs
+++ b/MCGalaxy/Commands/Information/CmdMapInfo.cs
@@ -245,9 +245,11 @@ namespace MCGalaxy.Commands {
public void FromOfflineLevel(string name) {
this.Name = name;
- LvlImporter.LoadDimensions(LevelInfo.LevelPath(name),
- out Width, out Height, out Length);
- string path = LevelInfo.FindPropertiesFile(name);
+ string path = LevelInfo.LevelPath(name);
+ Vec3U16 dims = IMapImporter.Formats[0].ReadDimensions(path);
+ Width = dims.X; Height = dims.Y; Length = dims.Z;
+
+ path = LevelInfo.FindPropertiesFile(name);
if (path != null)
PropertiesFile.Read(path, ParseProperty, '=');
if (Authors == null) Authors = "";
diff --git a/MCGalaxy/Database/BlockDB/DBExporter.cs b/MCGalaxy/Database/BlockDB/DBExporter.cs
index a10e34081..b9ced32de 100644
--- a/MCGalaxy/Database/BlockDB/DBExporter.cs
+++ b/MCGalaxy/Database/BlockDB/DBExporter.cs
@@ -44,7 +44,6 @@ namespace MCGalaxy.DB {
void DumpRow(IDataReader reader) {
if (stream == null) {
stream = File.Create("blockdefs/" + mapName + ".dump");
- Vec3U16 dims = L
}
string user = reader.GetString(0);
diff --git a/MCGalaxy/Levels/IO/Importers/CwImporter.cs b/MCGalaxy/Levels/IO/Importers/CwImporter.cs
index be46f6a86..148d4fd4d 100644
--- a/MCGalaxy/Levels/IO/Importers/CwImporter.cs
+++ b/MCGalaxy/Levels/IO/Importers/CwImporter.cs
@@ -23,6 +23,10 @@ namespace MCGalaxy.Levels.IO {
public sealed class CwImporter : IMapImporter {
public override string Extension { get { return ".cw"; } }
+
+ public override Vec3U16 ReadDimensions(Stream src) {
+ throw new NotSupportedException();
+ }
public override Level Read(Stream src, string name, bool metadata) {
NbtFile file = new NbtFile();
diff --git a/MCGalaxy/Levels/IO/Importers/DatImporter.cs b/MCGalaxy/Levels/IO/Importers/DatImporter.cs
index 7180c67eb..0ed965623 100644
--- a/MCGalaxy/Levels/IO/Importers/DatImporter.cs
+++ b/MCGalaxy/Levels/IO/Importers/DatImporter.cs
@@ -40,6 +40,10 @@ namespace MCGalaxy.Levels.IO {
public sealed class DatImporter : IMapImporter {
public override string Extension { get { return ".dat"; } }
+
+ public override Vec3U16 ReadDimensions(Stream src) {
+ throw new NotSupportedException();
+ }
public override Level Read(Stream src, string name, bool metadata) {
byte[] temp = new byte[8];
diff --git a/MCGalaxy/Levels/IO/Importers/FcmImporter.cs b/MCGalaxy/Levels/IO/Importers/FcmImporter.cs
index 5d4e3dd8e..6502a2c4f 100644
--- a/MCGalaxy/Levels/IO/Importers/FcmImporter.cs
+++ b/MCGalaxy/Levels/IO/Importers/FcmImporter.cs
@@ -61,7 +61,6 @@ namespace MCGalaxy.Levels.IO {
}
static Vec3U16 ReadDimensions(BinaryReader reader) {
- BinaryReader reader = new BinaryReader(src);
if (reader.ReadInt32() != 0x0FC2AF40 || reader.ReadByte() != 13) {
throw new InvalidDataException( "Unexpected constant in .fcm file" );
}
diff --git a/MCGalaxy/Levels/IO/Importers/McfImporter.cs b/MCGalaxy/Levels/IO/Importers/McfImporter.cs
index 4964194a4..7b470b4ac 100644
--- a/MCGalaxy/Levels/IO/Importers/McfImporter.cs
+++ b/MCGalaxy/Levels/IO/Importers/McfImporter.cs
@@ -31,7 +31,7 @@ namespace MCGalaxy.Levels.IO {
public override Vec3U16 ReadDimensions(Stream src) {
using (Stream gs = new GZipStream(src, CompressionMode.Decompress, true)) {
byte[] header = new byte[16];
- return ReadHeader(gs, header);
+ return ReadHeader(header, gs);
}
}
diff --git a/MCGalaxy/Levels/IO/MapFormats.cs b/MCGalaxy/Levels/IO/MapFormats.cs
index f40cebb71..4d34be05d 100644
--- a/MCGalaxy/Levels/IO/MapFormats.cs
+++ b/MCGalaxy/Levels/IO/MapFormats.cs
@@ -30,15 +30,20 @@ namespace MCGalaxy.Levels.IO {
/// Reads the data for a level from a file containing data encoded in this format.
/// Whether metadata should be loaded.
public Level Read(string path, string name, bool metadata) {
- using (FileStream fs = File.OpenRead(path)) {
+ using (FileStream fs = File.OpenRead(path))
return Read(fs, name, metadata);
- }
}
/// Reads the data for a level from a file containing data encoded in this format.
/// Whether metadata should be loaded.
public abstract Level Read(Stream src, string name, bool metadata);
+ /// Reads the dimensions for a level from a file containing data encoded in this format.
+ public Vec3U16 ReadDimensions(string path) {
+ using (FileStream fs = File.OpenRead(path))
+ return ReadDimensions(fs);
+ }
+
/// Reads the dimensions for a level from a file containing data encoded in this format.
public abstract Vec3U16 ReadDimensions(Stream src);
@@ -59,7 +64,7 @@ namespace MCGalaxy.Levels.IO {
}
}
- /// Writes/Saves block data (and potentially metadata) encoded in a particular format.
+ /// Writes/Saves block data (and potentially metadata) encoded in a particular format.
public abstract class IMapExporter {
/// The file extension of this format.
diff --git a/MCGalaxy/Player/Undo/UndoFormatCBin.cs b/MCGalaxy/Player/Undo/UndoFormatCBin.cs
index 6ee83bc76..a211db08e 100644
--- a/MCGalaxy/Player/Undo/UndoFormatCBin.cs
+++ b/MCGalaxy/Player/Undo/UndoFormatCBin.cs
@@ -49,9 +49,8 @@ namespace MCGalaxy.Undo {
continue;
}
- ushort width, height, length;
- LvlImporter.LoadDimensions(LevelInfo.LevelPath(uP.mapName), out width, out height, out length);
- node.Width = width; node.Height = height; node.Length = length;
+ Vec3U16 dims = IMapImporter.Formats[0].ReadDimensions(LevelInfo.LevelPath(uP.mapName));
+ node.Width = dims.X; node.Height = dims.Y; node.Length = dims.Z;
WriteChunkEntries(w, last.Entries, entriesPos);
node.MapName = uP.mapName;
last = WriteEmptyChunk(w, node, time, ref entriesPos);