using System;
+using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
if (mapChunk == null)
{
+ //TODO: REVISIT THIS CHUNK!
Logger.Warning("SKIP CHUNK: ({0}) - Map Chunk NULL!", mostActiveCol.Key);
nullMapCount++;
columnCounter.TryRemove(mostActiveCol.Key, out ejectedItem);
if (chunkTopMetadata.Contains(mostActiveCol.Key))
{
chunkMeta = chunkTopMetadata[mostActiveCol.Key];
-#if DEBUG
- Logger.VerboseDebug("Loaded chunk {0}", mostActiveCol.Key);
-#endif
+ #if DEBUG
+ Logger.VerboseDebug("Loaded meta-chunk {0}", mostActiveCol.Key);
+ #endif
}
else
{
chunkMeta = CreateColumnMetadata(mostActiveCol, mapChunk);
-#if DEBUG
- Logger.VerboseDebug("Created chunk {0}", mostActiveCol.Key);
-#endif
+ #if DEBUG
+ Logger.VerboseDebug("Created meta-chunk {0}", mostActiveCol.Key);
+ #endif
}
ProcessChunkBlocks(mostActiveCol.Key, mapChunk, ref chunkMeta);
if (updatedPixels > 0)
{
-#if DEBUG
- Logger.VerboseDebug("Wrote chunk shard: ({0}) - Edits#:{1}, Pixels#:{2}", mostActiveCol.Key, mostActiveCol.Value, updatedPixels);
-#endif
+ #if DEBUG
+ Logger.VerboseDebug("Wrote top-chunk shard: ({0}) - Edits#:{1}, Pixels#:{2}", mostActiveCol.Key, mostActiveCol.Value, updatedPixels);
+ #endif
updatedChunks++;
chunkTopMetadata.Update(chunkMeta);
columnCounter.TryRemove(mostActiveCol.Key, out ejectedItem);
else
{
columnCounter.TryRemove(mostActiveCol.Key, out ejectedItem);
-#if DEBUG
- Logger.VerboseDebug("Un-painted chunk: ({0}) ", mostActiveCol.Key);
-#endif
+ #if DEBUG
+ Logger.VerboseDebug("Un-painted chun shard: ({0}) ", mostActiveCol.Key);
+ #endif
}
}
//Cleanup persisted Metadata...
nullChunkCount++;
continue;
}
- worldChunk.Unpack( );//RESEARCH: Thread Unsafe?
+ if (worldChunk.IsPacked())
+ {
+ Logger.VerboseDebug("WORLD chunk: Compressed: X{0} Y{1} Z{2}", key.X, targetChunkY, key.Y);
+ worldChunk.Unpack( );//RESEARCH: Thread Unsafe?
+ }
/*************** Chunk Entities Scanning *********************/
if (worldChunk.BlockEntities != null && worldChunk.BlockEntities.Count > 0)
{
#if DEBUG
- Logger.VerboseDebug("Surface@ {0} = BlockEntities: {1}", key, worldChunk.BlockEntities.Count);
+ Logger.VerboseDebug("Scan pos.({0}) for BlockEntities# {1}", key, worldChunk.BlockEntities.Count);
#endif
foreach (var blockEnt in worldChunk.BlockEntities)
}
}
+ //NOTE: Temporary; remove - replace later
+ if (chunkMeta.ColumnPresense == null) { chunkMeta.ColumnPresense = new BitArray((ClientAPI.World.BlockAccessor.MapSizeY / chunkSize), false); }
chunkMeta.ColumnPresense[targetChunkY] = true;
/********************* Chunk/Column BLOCKs scanning ****************/
if (chunkMeta.HeightMap == null) { chunkMeta.HeightMap = new ushort[chunkSize, chunkSize]; }
if (chunkMeta.RockRatio == null) { chunkMeta.RockRatio = new Dictionary<int, uint>(10); }
+ //First Chance fail-safe;
+ if (worldChunk.Blocks == null || worldChunk.Blocks.Length <= 0) {
+ Logger.VerboseDebug("WORLD chunk; Missing block DATA⁈ X{0} Y{1} Z{2} ⁈", key.X, targetChunkY, key.Y);
+ continue;
+ }
+
for (Y_index = 0; Y_index < chunkSize - 1; Y_index++)
{
for (Z_index = 0; Z_index < chunkSize - 1; Z_index++)
{
for (X_index = 0; X_index < chunkSize - 1; X_index++)
{
- /* Encode packed indicie
- (y * chunksize + z) * chunksize + x
- */
- var indicie = Helpers.ChunkBlockIndicie16(X_index, Y_index, Z_index);
- int aBlockId = worldChunk.Blocks[indicie];
-
- if (aBlockId == 0)
- {//Air
- chunkMeta.AirBlocks++;
- continue;
- }
-
- if (RockIdCodes.ContainsKey(aBlockId))
- {
- if (chunkMeta.RockRatio.ContainsKey(aBlockId))
- chunkMeta.RockRatio[aBlockId]++;
- else
- chunkMeta.RockRatio.Add(aBlockId, 1);
- }
-
- chunkMeta.NonAirBlocks++;
-
- //Heightmap
- if (chunkMeta.HeightMap[X_index, Z_index] == 0)
- {
- chunkMeta.HeightMap[X_index, Z_index] = (ushort) (Y_index + (targetChunkY * chunkSize));
- }
+ /* Encode packed indicie
+ (y * chunksize + z) * chunksize + x
+ */
+ var indicie = Helpers.ChunkBlockIndicie16(X_index, Y_index, Z_index);
+
+ //'Last' Chance fail-safe;
+ if (worldChunk.Blocks == null || worldChunk.Blocks.Length <= 0) {
+ Logger.VerboseDebug("Processing Block: Missing block DATA⁈ X{0} Y{1} Z{2} ⁈", X_index, Y_index, Z_index);
+ goto loop_bustout;;
}
- }
+
+ int aBlockId = worldChunk.Blocks[indicie];
- }
+ if (aBlockId == 0)
+ {//Air
+ chunkMeta.AirBlocks++;
+ continue;
+ }
+
+ if (RockIdCodes.ContainsKey(aBlockId))
+ {
+ if (chunkMeta.RockRatio.ContainsKey(aBlockId))
+ chunkMeta.RockRatio[aBlockId]++;
+ else
+ chunkMeta.RockRatio.Add(aBlockId, 1);
+ }
+ chunkMeta.NonAirBlocks++;
+
+ //Heightmap
+ if (chunkMeta.HeightMap[X_index, Z_index] == 0)
+ {
+ chunkMeta.HeightMap[X_index, Z_index] = (ushort) (Y_index + (targetChunkY * chunkSize));
+ }
+ }
+ }
+ }
+ loop_bustout:;
}
}
--- /dev/null
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes.
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle("ShardProcessor")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("librarian")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion("1.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly,
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
+
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+ <PropertyGroup>\r
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
+ <ProjectGuid>{837EE90B-7C03-413B-B54D-B50B2ED1EC00}</ProjectGuid>\r
+ <OutputType>Exe</OutputType>\r
+ <RootNamespace>ShardProcessor</RootNamespace>\r
+ <AssemblyName>ShardProcessor</AssemblyName>\r
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+ <DebugSymbols>true</DebugSymbols>\r
+ <DebugType>full</DebugType>\r
+ <Optimize>false</Optimize>\r
+ <OutputPath>bin\Debug</OutputPath>\r
+ <DefineConstants>DEBUG;</DefineConstants>\r
+ <ErrorReport>prompt</ErrorReport>\r
+ <WarningLevel>4</WarningLevel>\r
+ <ExternalConsole>true</ExternalConsole>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
+ <Optimize>true</Optimize>\r
+ <OutputPath>bin\Release</OutputPath>\r
+ <ErrorReport>prompt</ErrorReport>\r
+ <WarningLevel>4</WarningLevel>\r
+ <ExternalConsole>true</ExternalConsole>\r
+ </PropertyGroup>\r
+ <ItemGroup>\r
+ <Reference Include="System" />\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <Compile Include="Program.cs" />\r
+ <Compile Include="Properties\AssemblyInfo.cs" />\r
+ </ItemGroup>\r
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />\r
+</Project>
\ No newline at end of file