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-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
|
|
|
|
{
|
|
|
|
|
string cx64 = Base64(cx);
|
|
|
|
|
string cz64 = Base64(cz);
|
|
|
|
|
string file = "c." + cx64 + "." + cz64 + ".dat";
|
|
|
|
|
|
|
|
|
|
string dir1 = Base64(cx % 64);
|
|
|
|
|
string dir2 = Base64(cz % 64);
|
|
|
|
|
|
|
|
|
|
_filename = Path.Combine(path, dir1);
|
|
|
|
|
_filename = Path.Combine(_filename, dir2);
|
|
|
|
|
_filename = Path.Combine(_filename, file);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string Base64 (int val)
|
|
|
|
|
{
|
|
|
|
|
return Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(val.ToString()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|