2011-04-14 07:04:13 +00:00
|
|
|
|
using System;
|
|
|
|
|
using Substrate;
|
|
|
|
|
|
|
|
|
|
namespace Relight
|
|
|
|
|
{
|
|
|
|
|
class Program
|
|
|
|
|
{
|
|
|
|
|
static void Main (string[] args)
|
|
|
|
|
{
|
|
|
|
|
if (args.Length < 1) {
|
|
|
|
|
Console.WriteLine("You must specify a target directory");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
string dest = args[0];
|
|
|
|
|
|
|
|
|
|
// Load the world, supporting either alpha or beta format
|
|
|
|
|
INBTWorld world;
|
|
|
|
|
if (args.Length >= 2 && args[1] == "alpha") {
|
|
|
|
|
world = AlphaWorld.Open(dest);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
world = BetaWorld.Open(dest);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Grab a generic chunk manager reference
|
|
|
|
|
IChunkManager cm = world.GetChunkManager();
|
|
|
|
|
|
|
|
|
|
// First blank out all of the lighting in all of the chunks
|
|
|
|
|
foreach (ChunkRef chunk in cm) {
|
2011-05-13 03:09:57 +00:00
|
|
|
|
if (chunk.X < -20 || chunk.X > 0 || chunk.Z < -20 || chunk.Z > 0) continue;
|
|
|
|
|
|
|
|
|
|
chunk.Blocks.RebuildHeightMap();
|
|
|
|
|
chunk.Blocks.ResetBlockLight();
|
|
|
|
|
chunk.Blocks.ResetBlockSkyLight();
|
2011-04-14 07:04:13 +00:00
|
|
|
|
cm.Save();
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("Reset Chunk {0},{1}", chunk.X, chunk.Z);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// In a separate pass, reconstruct the light
|
|
|
|
|
foreach (ChunkRef chunk in cm) {
|
2011-05-13 03:09:57 +00:00
|
|
|
|
if (chunk.X < -20 || chunk.X > 0 || chunk.Z < -20 || chunk.Z > 0) continue;
|
|
|
|
|
|
|
|
|
|
chunk.Blocks.RebuildBlockLight();
|
|
|
|
|
chunk.Blocks.RebuildBlockSkyLight();
|
2011-04-14 07:04:13 +00:00
|
|
|
|
|
|
|
|
|
// Save the chunk to disk so it doesn't hang around in RAM
|
|
|
|
|
cm.Save();
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("Lit Chunk {0},{1}", chunk.X, chunk.Z);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|