forked from mirrors/NBTExplorer
Numerous fixes to get the library to actually run with software. Rebuilt Ionic.Zlib to incorporate critical patch to Addler32.
This commit is contained in:
parent
1e029325bc
commit
e8a99d62a9
10 changed files with 71 additions and 32 deletions
Binary file not shown.
|
@ -214,17 +214,17 @@ namespace Substrate
|
||||||
|
|
||||||
public int XDim
|
public int XDim
|
||||||
{
|
{
|
||||||
get { return _chunk.XDim; }
|
get { return 16; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public int YDim
|
public int YDim
|
||||||
{
|
{
|
||||||
get { return _chunk.YDim; }
|
get { return 128; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ZDim
|
public int ZDim
|
||||||
{
|
{
|
||||||
get { return _chunk.ZDim; }
|
get { return 16; }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -10,22 +10,7 @@ namespace Substrate
|
||||||
|
|
||||||
public class Level : INBTObject<Level>, ICopyable<Level>
|
public class Level : INBTObject<Level>, ICopyable<Level>
|
||||||
{
|
{
|
||||||
public static NBTCompoundNode LevelSchema = new NBTCompoundNode()
|
public static NBTCompoundNode LevelSchema;
|
||||||
{
|
|
||||||
new NBTCompoundNode("Data")
|
|
||||||
{
|
|
||||||
new NBTScalerNode("Time", NBT_Type.TAG_LONG),
|
|
||||||
new NBTScalerNode("LastPlayed", NBT_Type.TAG_LONG),
|
|
||||||
new NBTCompoundNode("Player", Player.PlayerSchema),
|
|
||||||
new NBTScalerNode("SpawnX", NBT_Type.TAG_INT),
|
|
||||||
new NBTScalerNode("SpawnY", NBT_Type.TAG_INT),
|
|
||||||
new NBTScalerNode("SpawnZ", NBT_Type.TAG_INT),
|
|
||||||
new NBTScalerNode("SizeOnDisk", NBT_Type.TAG_LONG),
|
|
||||||
new NBTScalerNode("RandomSeed", NBT_Type.TAG_LONG),
|
|
||||||
new NBTScalerNode("Version", NBT_Type.TAG_INT, NBTOptions.OPTIONAL),
|
|
||||||
new NBTScalerNode("LevelName", NBT_Type.TAG_STRING, NBTOptions.OPTIONAL),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
private World _world;
|
private World _world;
|
||||||
|
|
||||||
|
@ -103,6 +88,23 @@ namespace Substrate
|
||||||
public Level (World world)
|
public Level (World world)
|
||||||
{
|
{
|
||||||
_world = world;
|
_world = world;
|
||||||
|
|
||||||
|
LevelSchema = new NBTCompoundNode()
|
||||||
|
{
|
||||||
|
new NBTCompoundNode("Data")
|
||||||
|
{
|
||||||
|
new NBTScalerNode("Time", NBT_Type.TAG_LONG),
|
||||||
|
new NBTScalerNode("LastPlayed", NBT_Type.TAG_LONG),
|
||||||
|
new NBTCompoundNode("Player", Player.PlayerSchema, NBTOptions.OPTIONAL),
|
||||||
|
new NBTScalerNode("SpawnX", NBT_Type.TAG_INT),
|
||||||
|
new NBTScalerNode("SpawnY", NBT_Type.TAG_INT),
|
||||||
|
new NBTScalerNode("SpawnZ", NBT_Type.TAG_INT),
|
||||||
|
new NBTScalerNode("SizeOnDisk", NBT_Type.TAG_LONG),
|
||||||
|
new NBTScalerNode("RandomSeed", NBT_Type.TAG_LONG),
|
||||||
|
new NBTScalerNode("version", NBT_Type.TAG_INT, NBTOptions.OPTIONAL),
|
||||||
|
new NBTScalerNode("LevelName", NBT_Type.TAG_STRING, NBTOptions.OPTIONAL),
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public Level (Level p)
|
public Level (Level p)
|
||||||
|
@ -157,7 +159,9 @@ namespace Substrate
|
||||||
_time = ctree["Time"].ToNBTLong();
|
_time = ctree["Time"].ToNBTLong();
|
||||||
_lastPlayed = ctree["LastPlayed"].ToNBTLong();
|
_lastPlayed = ctree["LastPlayed"].ToNBTLong();
|
||||||
|
|
||||||
|
if (ctree.ContainsKey("Player")) {
|
||||||
_player = new Player().LoadTree(ctree["Player"]);
|
_player = new Player().LoadTree(ctree["Player"]);
|
||||||
|
}
|
||||||
|
|
||||||
_spawnX = ctree["SpawnX"].ToNBTInt();
|
_spawnX = ctree["SpawnX"].ToNBTInt();
|
||||||
_spawnY = ctree["SpawnY"].ToNBTInt();
|
_spawnY = ctree["SpawnY"].ToNBTInt();
|
||||||
|
@ -166,8 +170,8 @@ namespace Substrate
|
||||||
_sizeOnDisk = ctree["SizeOnDisk"].ToNBTLong();
|
_sizeOnDisk = ctree["SizeOnDisk"].ToNBTLong();
|
||||||
_randomSeed = ctree["RandomSeed"].ToNBTLong();
|
_randomSeed = ctree["RandomSeed"].ToNBTLong();
|
||||||
|
|
||||||
if (ctree.ContainsKey("Version")) {
|
if (ctree.ContainsKey("version")) {
|
||||||
_version = ctree["Version"].ToNBTInt();
|
_version = ctree["version"].ToNBTInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctree.ContainsKey("LevelName")) {
|
if (ctree.ContainsKey("LevelName")) {
|
||||||
|
@ -191,7 +195,11 @@ namespace Substrate
|
||||||
NBT_Compound data = new NBT_Compound();
|
NBT_Compound data = new NBT_Compound();
|
||||||
data["Time"] = new NBT_Long(_time);
|
data["Time"] = new NBT_Long(_time);
|
||||||
data["LastPlayed"] = new NBT_Long(_lastPlayed);
|
data["LastPlayed"] = new NBT_Long(_lastPlayed);
|
||||||
|
|
||||||
|
if (_player != null) {
|
||||||
data["Player"] = _player.BuildTree();
|
data["Player"] = _player.BuildTree();
|
||||||
|
}
|
||||||
|
|
||||||
data["SpawnX"] = new NBT_Int(_spawnX);
|
data["SpawnX"] = new NBT_Int(_spawnX);
|
||||||
data["SpawnY"] = new NBT_Int(_spawnY);
|
data["SpawnY"] = new NBT_Int(_spawnY);
|
||||||
data["SpawnZ"] = new NBT_Int(_spawnZ);
|
data["SpawnZ"] = new NBT_Int(_spawnZ);
|
||||||
|
@ -199,7 +207,7 @@ namespace Substrate
|
||||||
data["RandomSeed"] = new NBT_Long(_randomSeed);
|
data["RandomSeed"] = new NBT_Long(_randomSeed);
|
||||||
|
|
||||||
if (_version != null) {
|
if (_version != null) {
|
||||||
data["Version"] = new NBT_Int(_version ?? 0);
|
data["version"] = new NBT_Int(_version ?? 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_name != null) {
|
if (_name != null) {
|
||||||
|
|
|
@ -4,7 +4,7 @@ using System.Text;
|
||||||
|
|
||||||
namespace Substrate.NBT
|
namespace Substrate.NBT
|
||||||
{
|
{
|
||||||
class JSONSerializer
|
public class JSONSerializer
|
||||||
{
|
{
|
||||||
public static string Serialize (NBT_Value tag)
|
public static string Serialize (NBT_Value tag)
|
||||||
{
|
{
|
||||||
|
|
|
@ -354,6 +354,8 @@ namespace Substrate.NBT
|
||||||
public NBTCompoundNode (string name, NBTSchemaNode subschema)
|
public NBTCompoundNode (string name, NBTSchemaNode subschema)
|
||||||
: base(name)
|
: base(name)
|
||||||
{
|
{
|
||||||
|
_subnodes = new List<NBTSchemaNode>();
|
||||||
|
|
||||||
NBTCompoundNode schema = subschema as NBTCompoundNode;
|
NBTCompoundNode schema = subschema as NBTCompoundNode;
|
||||||
if (schema == null) {
|
if (schema == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -368,6 +370,8 @@ namespace Substrate.NBT
|
||||||
public NBTCompoundNode (string name, NBTSchemaNode subschema, NBTOptions options)
|
public NBTCompoundNode (string name, NBTSchemaNode subschema, NBTOptions options)
|
||||||
: base(name, options)
|
: base(name, options)
|
||||||
{
|
{
|
||||||
|
_subnodes = new List<NBTSchemaNode>();
|
||||||
|
|
||||||
NBTCompoundNode schema = subschema as NBTCompoundNode;
|
NBTCompoundNode schema = subschema as NBTCompoundNode;
|
||||||
if (schema == null) {
|
if (schema == null) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -143,7 +143,10 @@ namespace Substrate
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new NBT_Tree(nbtstr);
|
NBT_Tree tree = new NBT_Tree(nbtstr);
|
||||||
|
|
||||||
|
nbtstr.Close();
|
||||||
|
return tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SaveChunkTree (int lcx, int lcz, NBT_Tree tree)
|
public bool SaveChunkTree (int lcx, int lcz, NBT_Tree tree)
|
||||||
|
|
|
@ -237,14 +237,24 @@ namespace Substrate
|
||||||
byte[] data = new byte[length - 1];
|
byte[] data = new byte[length - 1];
|
||||||
file.Read(data, 0, data.Length);
|
file.Read(data, 0, data.Length);
|
||||||
Stream ret = new GZipStream(new MemoryStream(data), CompressionMode.Decompress);
|
Stream ret = new GZipStream(new MemoryStream(data), CompressionMode.Decompress);
|
||||||
// Debug("READ", x, z, " = found");
|
|
||||||
return ret;
|
return ret;
|
||||||
} else if (version == VERSION_DEFLATE) {
|
}
|
||||||
|
else if (version == VERSION_DEFLATE) {
|
||||||
byte[] data = new byte[length - 1];
|
byte[] data = new byte[length - 1];
|
||||||
file.Read(data, 0, data.Length);
|
file.Read(data, 0, data.Length);
|
||||||
|
|
||||||
Stream ret = new ZlibStream(new MemoryStream(data), CompressionMode.Decompress, true);
|
Stream ret = new ZlibStream(new MemoryStream(data), CompressionMode.Decompress, true);
|
||||||
// Debug("READ", x, z, " = found");
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
/*MemoryStream sinkZ = new MemoryStream();
|
||||||
|
ZlibStream zOut = new ZlibStream(sinkZ, CompressionMode.Decompress, true);
|
||||||
|
zOut.Write(data, 0, data.Length);
|
||||||
|
zOut.Flush();
|
||||||
|
zOut.Close();
|
||||||
|
|
||||||
|
sinkZ.Seek(0, SeekOrigin.Begin);
|
||||||
|
return sinkZ;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
Debugln("READ", x, z, "unknown version " + version);
|
Debugln("READ", x, z, "unknown version " + version);
|
||||||
|
|
|
@ -61,7 +61,10 @@ namespace Substrate
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_level = new Level(this).LoadTreeSafe(new NBT_Tree(nbtstr).Root);
|
NBT_Tree tree = new NBT_Tree(nbtstr);
|
||||||
|
|
||||||
|
_level = new Level(this);
|
||||||
|
_level = _level.LoadTreeSafe(tree.Root);
|
||||||
|
|
||||||
return _level != null;
|
return _level != null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,13 +54,12 @@
|
||||||
</DocumentationFile>
|
</DocumentationFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Ionic.Zlib, Version=1.9.1.5, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c, processorArchitecture=MSIL">
|
<Reference Include="Ionic.Zlib, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>Assemblies\Ionic.Zlib.dll</HintPath>
|
<HintPath>Assemblies\Ionic.Zlib.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Source\Level.cs" />
|
<Compile Include="Source\Level.cs" />
|
||||||
|
|
|
@ -3,6 +3,10 @@ Microsoft Visual Studio Solution File, Format Version 10.00
|
||||||
# Visual C# Express 2008
|
# Visual C# Express 2008
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Substrate", "Substrate.csproj", "{AFE30E14-3F2F-4461-9F7D-147AB4DCA4C3}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Substrate", "Substrate.csproj", "{AFE30E14-3F2F-4461-9F7D-147AB4DCA4C3}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NBToolkit", "..\..\NBToolkit\NBToolkit.csproj", "{68207314-C080-4823-97F1-A6623145AA00}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ionic.Zlib", "..\..\Ionic.Zlib\Ionic.Zlib.csproj", "{5A137E43-7E7B-4696-8BFC-844CACAB144B}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -13,6 +17,14 @@ Global
|
||||||
{AFE30E14-3F2F-4461-9F7D-147AB4DCA4C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{AFE30E14-3F2F-4461-9F7D-147AB4DCA4C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{AFE30E14-3F2F-4461-9F7D-147AB4DCA4C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{AFE30E14-3F2F-4461-9F7D-147AB4DCA4C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{AFE30E14-3F2F-4461-9F7D-147AB4DCA4C3}.Release|Any CPU.Build.0 = Release|Any CPU
|
{AFE30E14-3F2F-4461-9F7D-147AB4DCA4C3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{68207314-C080-4823-97F1-A6623145AA00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{68207314-C080-4823-97F1-A6623145AA00}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{68207314-C080-4823-97F1-A6623145AA00}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{68207314-C080-4823-97F1-A6623145AA00}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{5A137E43-7E7B-4696-8BFC-844CACAB144B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{5A137E43-7E7B-4696-8BFC-844CACAB144B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{5A137E43-7E7B-4696-8BFC-844CACAB144B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{5A137E43-7E7B-4696-8BFC-844CACAB144B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
Loading…
Reference in a new issue