2011-04-06 04:43:54 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using Ionic.Zlib;
|
|
|
|
|
|
2011-04-06 21:20:35 +00:00
|
|
|
|
namespace Substrate
|
2011-04-06 04:43:54 +00:00
|
|
|
|
{
|
2011-04-08 23:16:04 +00:00
|
|
|
|
using Utility;
|
|
|
|
|
|
2011-04-07 07:03:54 +00:00
|
|
|
|
public class ChunkFile : NBTFile
|
2011-04-06 04:43:54 +00:00
|
|
|
|
{
|
|
|
|
|
public ChunkFile (string path)
|
2011-04-07 07:03:54 +00:00
|
|
|
|
: base(path)
|
2011-04-06 04:43:54 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ChunkFile (string path, int cx, int cz)
|
2011-04-07 07:03:54 +00:00
|
|
|
|
: base("")
|
2011-04-06 04:43:54 +00:00
|
|
|
|
{
|
2011-04-08 23:16:04 +00:00
|
|
|
|
string cx64 = Base36.Encode(cx);
|
|
|
|
|
string cz64 = Base36.Encode(cz);
|
2011-04-06 04:43:54 +00:00
|
|
|
|
string file = "c." + cx64 + "." + cz64 + ".dat";
|
|
|
|
|
|
2011-04-08 23:16:04 +00:00
|
|
|
|
while (cx < 0) {
|
|
|
|
|
cx += (64 * 64);
|
|
|
|
|
}
|
|
|
|
|
while (cz < 0) {
|
|
|
|
|
cz += (64 * 64);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string dir1 = Base36.Encode(cx % 64);
|
|
|
|
|
string dir2 = Base36.Encode(cz % 64);
|
2011-04-06 04:43:54 +00:00
|
|
|
|
|
|
|
|
|
_filename = Path.Combine(path, dir1);
|
2011-06-02 20:08:06 +00:00
|
|
|
|
if (!Directory.Exists(_filename)) {
|
|
|
|
|
Directory.CreateDirectory(_filename);
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-06 04:43:54 +00:00
|
|
|
|
_filename = Path.Combine(_filename, dir2);
|
2011-06-02 20:08:06 +00:00
|
|
|
|
if (!Directory.Exists(_filename)) {
|
|
|
|
|
Directory.CreateDirectory(_filename);
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-06 04:43:54 +00:00
|
|
|
|
_filename = Path.Combine(_filename, file);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|