+
+ private static void ArgsDecoder(string[ ] args)
+ {
+ //#1 Path to maps '~/ApplicationData/vintagestory/Map/World_1234567890
+ mapPath = args[1];
+
+ //#0 Command: Heightmaps (Generation from existing shard data)
+ string command = args[0];
+
+ if (command == "--heightmap") {
+ Process_ShardData( );
+ }
+
+ }
+
+ private static void Process_ShardData( )
+ {
+ var shardsDir = new DirectoryInfo( Path.Combine(mapPath , _chunkPath));
+
+ var shardFiles = shardsDir.GetFiles(chunkFile_filter);
+
+ if (shardFiles.Length > 0) {
+ #if DEBUG
+ //Logger.VerboseDebug("Metadata reloading from {0} shards", shardFiles.Length);
+ #endif
+
+ foreach (var shardFile in shardFiles) {
+
+ if (shardFile.Length < 1024) continue;
+ var result = chunkShardRegex.Match(shardFile.Name);
+ if (!result.Success) continue;
+
+ int X_chunk_pos = int.Parse(result.Groups["X"].Value);
+ int Z_chunk_pos = int.Parse(result.Groups["Z"].Value);
+
+ try {
+ using (var fileStream = shardFile.OpenRead( )) {
+
+ PngReader pngRead = new PngReader(fileStream);
+ pngRead.ReadSkippingAllRows( );
+ pngRead.End( );
+ //Parse PNG chunks for METADATA in shard
+ PngMetadataChunk metadataFromPng = pngRead.GetChunksList( ).GetById1(PngMetadataChunk.ID) as PngMetadataChunk;
+ ColumnMeta columnData = metadataFromPng.ChunkMetadata;
+ //columnData.HeightMap //Should be sane Heightmap...
+
+
+
+ }
+
+ } catch (PngjException someEx) {
+ //Logger.Error("PNG Corruption file '{0}' - Reason: {1}", shardFile.Name, someEx);
+ continue;
+ } catch (ProtoException protoEx) {
+ //Logger.Error("ProtoBuf invalid! file:'{0}' - Reason: {1}", shardFile.Name, protoEx);
+ continue;
+ }
+ }
+ }
+
+
+ }
+