Automap (client) [VS plugin mod]
Revision | a410dd36022b986917558b51791174d78375efdc (tree) |
---|---|
Time | 2021-05-22 10:18:32 |
Author | melchior <melchior@user...> |
Commiter | melchior |
Added Single Shard metadata dumper
@@ -1,4 +1,5 @@ | ||
1 | 1 | using System; |
2 | +using System.Diagnostics; | |
2 | 3 | using System.IO; |
3 | 4 | using System.Text.RegularExpressions; |
4 | 5 |
@@ -58,6 +59,10 @@ namespace ShardProcessor | ||
58 | 59 | Scan_PointsData( ); |
59 | 60 | break; |
60 | 61 | |
62 | + case @"--oneshard": | |
63 | + Scan_OneShard( ); | |
64 | + break; | |
65 | + | |
61 | 66 | default: |
62 | 67 | Console.WriteLine("Unrecognized Command: {0}", command); |
63 | 68 | break; |
@@ -250,5 +255,48 @@ namespace ShardProcessor | ||
250 | 255 | Console.WriteLine("Scanned {0} files, {1} errors, {2} FLAT entries", count, errors, flat); |
251 | 256 | } |
252 | 257 | |
258 | + private static void Scan_OneShard( ) | |
259 | + { | |
260 | + //--oneshard ~/ApplicationData/vintagestory/Maps/World_1316328588/Chunks/9363_9379.png | |
261 | + var oneChunkFile = new FileInfo(mapPath); | |
262 | + if (oneChunkFile.Exists) { | |
263 | + | |
264 | + | |
265 | + try { | |
266 | + using (var fileStream = oneChunkFile.OpenRead( )) { | |
267 | + | |
268 | + PngReader pngRead = new PngReader(fileStream); | |
269 | + pngRead.ReadSkippingAllRows( ); | |
270 | + | |
271 | + //Parse PNG chunks for METADATA in shard | |
272 | + PngMetadataChunk metadataFromPng = pngRead.GetChunksList( ).GetById1(PngMetadataChunk.ID) as PngMetadataChunk; | |
273 | + ColumnMeta columnData = metadataFromPng.ChunkMetadata; | |
274 | + var metadata = pngRead.GetMetadata( ); | |
275 | + var pngWriteTime = metadata.GetTime( ); | |
276 | + var chunkX = metadata.GetTxtForKey(@"Chunk_X"); | |
277 | + var chunkY = metadata.GetTxtForKey(@"Chunk_Y"); | |
278 | + var pixelSize = metadata.GetTxtForKey(@"PxSz"); | |
279 | + var gameDate = metadata.GetTxtForKey(@"GameDY"); | |
280 | + var dateBlob = pngWriteTime.GetYMDHMS( ); | |
281 | + /* | |
282 | + return new int[] { | |
283 | + this.year, | |
284 | + this.mon, | |
285 | + this.day, | |
286 | + this.hour, | |
287 | + this.min, | |
288 | + this.sec | |
289 | + */ | |
290 | + | |
291 | + Console.WriteLine($"PNG-Timestamp: Y{dateBlob[0] - 456960} M{dateBlob[1]} D{dateBlob[2]} H{dateBlob[3]} M {dateBlob[4]} S{dateBlob[5]} Chunk: X {chunkX} Y {chunkY} PixelSize:{pixelSize} Game-Date: {gameDate}"); | |
292 | + | |
293 | + pngRead.End( ); | |
294 | + } | |
295 | + } catch (Exception darn) { | |
296 | + Debug.Write("Oops! File causes: {0}", darn.ToString( )); | |
297 | + } | |
298 | + | |
299 | + } | |
300 | + } | |
253 | 301 | } |
254 | 302 | } |
@@ -18,7 +18,7 @@ | ||
18 | 18 | <ErrorReport>prompt</ErrorReport> |
19 | 19 | <WarningLevel>4</WarningLevel> |
20 | 20 | <ExternalConsole>true</ExternalConsole> |
21 | - <Commandlineparameters>--shards ~/ApplicationData/vintagestory/Maps/World_19781215</Commandlineparameters> | |
21 | + <Commandlineparameters></Commandlineparameters> | |
22 | 22 | </PropertyGroup> |
23 | 23 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
24 | 24 | <Optimize>true</Optimize> |