OSDN Git Service

Revisit(er) & ReadOnly chunk use
[automap/automap.git] / ShardProcessor / Program.cs
1 using System;
2 using System.Diagnostics;
3 using System.IO;
4 using System.Text.RegularExpressions;
5
6 using Automap;
7
8 using Hjg.Pngcs;
9 using Hjg.Pngcs.Chunks;
10
11 using ProtoBuf;
12 using Vintagestory.GameContent;
13
14 namespace ShardProcessor
15 {       
16         public partial class MainClass
17         {
18                 //private ILogger Logger { get; set; }
19                 const string chunkFile_filter = @"*_*.png";
20                 static Regex chunkShardRegex = new Regex(@"(?<X>[\d]+)_(?<Z>[\d]+)\.png", RegexOptions.Singleline);
21                 static string mapPath;
22                 internal const string _chunkPath = @"Chunks";
23                 internal const string _minimapTilesPath = @"Tiles";
24
25                 /* TODO:
26                         -Process existing PNGs: Report/Dump contents of Chunk Metadata, as per current version
27                         -Grayscale Heightmap extraction from P.Buf heightmap from shards
28                         -Extract contents of game's SQLLite map DB, INTO Automap type shards...
29                         -Other stuff? chunk fixing / validation?
30                 */
31                 public static void Main(string[ ] args)
32                 {
33                 Console.WriteLine("AUTOMAP Offline Shard processor v0.1");
34                 //Called once - thus it can only be in a static constructor.
35                 PngChunk.FactoryRegister(PngMetadataChunk.ID, typeof(PngMetadataChunk));
36
37                 ArgsDecoder(args);
38
39                 }
40
41                 private static void ArgsDecoder(string[ ] args)
42                 {
43                 //#1 Path to maps '~/ApplicationData/vintagestory/Map/World_1234567890
44                 mapPath = args.Length > 1 ? args[1] : String.Empty;
45
46                 //#0 Command: Heightmaps (Generation from existing shard data)
47                 string command = args[0];
48
49
50                 switch (command) {
51                         
52                         case @"--heightmap":
53                                 Process_ShardData( );
54                         break;
55
56                         case @"--shards":
57                                 Scan_ShardData( );
58                         break;
59
60                         case @"--points":
61                                 Scan_PointsData( );                     
62                         break;
63
64                         case @"--oneshard":
65                                 Scan_OneShard( );
66                         break;
67
68                         case @"--protoheader":
69                                 Emit_ProtoHeader();
70                         break;
71
72                         case "--minidump":
73                                 Dump_Minimap( );
74                         break;
75
76                 default:
77                         Console.WriteLine("Unrecognized Command: {0}", command);
78                         break;
79                 }
80
81                 
82
83                 }
84
85
86
87         }
88 }