Bugfixes for creating new worlds/regions/chunks

This commit is contained in:
Justin Aquadro 2011-04-13 07:09:41 +00:00
parent 4141175491
commit c6ee97a53b
5 changed files with 19 additions and 4 deletions

View file

@ -246,9 +246,6 @@ namespace Substrate
}
if (MoveNextInRegion()) {
_chunk = _region.GetChunkRef(_x, _z, _cm);
if (_chunk == null) {
throw new Exception();
}
return true;
}
}

View file

@ -576,6 +576,10 @@ namespace Substrate
private ChunkRef LocalChunk (int lx, int ly, int lz)
{
if (ly < 0 || ly >= YDim) {
return null;
}
if (lx < 0) {
if (lz < 0) {
return _container.GetChunkRef(_cx - 1, _cz - 1);

View file

@ -102,6 +102,8 @@ namespace Substrate
file.Write(int0, 0, 4);
}
file.Flush();
sizeDelta += SECTOR_BYTES * 2;
}
@ -110,6 +112,8 @@ namespace Substrate
for (int i = 0; i < (file.Length & 0xfff); ++i) {
file.WriteByte(0);
}
file.Flush();
}
/* set up the available sector map */

View file

@ -60,9 +60,14 @@ namespace Substrate
Region r = GetRegion(rx, rz);
if (r == null) {
string fp = "r." + rx + "." + rz + ".mcr";
new RegionFile(Path.Combine(_regionPath, fp));
using (RegionFile rf = new RegionFile(Path.Combine(_regionPath, fp))) {
}
r = new Region(this, rx, rz);
RegionKey k = new RegionKey(rx, rz);
_cache[k] = r;
}
return r;

View file

@ -335,6 +335,11 @@ namespace Substrate
throw new DirectoryNotFoundException("Directory '" + path + "' not found");
}
string regpath = Path.Combine(path, _REGION_DIR);
if (!Directory.Exists(regpath)) {
Directory.CreateDirectory(regpath);
}
_path = path;
_level = new Level(this);