• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Automap (client) [VS plugin mod]


Commit MetaInfo

修訂ec3438c8c02c57ac0241b388851e659b1cc0fc65 (tree)
時間2020-11-08 05:15:59
作者melchior <melchior@user...>
Commitermelchior

Log Message

W.I.P. P.O.C. Shard Post Processor Skeliton

Change Summary

差異

--- a/ShardProcessor/Program.cs
+++ b/ShardProcessor/Program.cs
@@ -1,19 +1,101 @@
11 using System;
2+using System.IO;
3+using System.Text.RegularExpressions;
4+
5+using Automap;
6+
7+using Hjg.Pngcs;
8+using Hjg.Pngcs.Chunks;
9+
10+using ProtoBuf;
211
312 namespace ShardProcessor
4-{
13+{
514 class MainClass
615 {
7- /*
16+ //private ILogger Logger { get; set; }
17+ const string chunkFile_filter = @"*_*.png";
18+ static Regex chunkShardRegex = new Regex(@"(?<X>[\d]+)_(?<Z>[\d]+)\.png", RegexOptions.Singleline);
19+ static string mapPath;
20+ internal const string _chunkPath = @"Chunks";
21+
22+ /* TODO:
823 -Process existing PNGs: Report/Dump contents of Chunk Metadata, as per current version
24+ -Grayscale Heightmap extraction from P.Buf heightmap from shards
925 -Extract contents of game's SQLLite map DB, INTO Automap type shards...
1026 -Other stuff? chunk fixing / validation?
1127 */
1228 public static void Main(string[ ] args)
1329 {
1430 Console.WriteLine("AUTOMAP Offline Shard processor v0.1");
31+ //Called once - thus it can only be in a static constructor.
32+ PngChunk.FactoryRegister(PngMetadataChunk.ID, typeof(PngMetadataChunk));
1533
34+ ArgsDecoder(args);
1635
1736 }
37+
38+ private static void ArgsDecoder(string[ ] args)
39+ {
40+ //#1 Path to maps '~/ApplicationData/vintagestory/Map/World_1234567890
41+ mapPath = args[1];
42+
43+ //#0 Command: Heightmaps (Generation from existing shard data)
44+ string command = args[0];
45+
46+ if (command == "--heightmap") {
47+ Process_ShardData( );
48+ }
49+
50+ }
51+
52+ private static void Process_ShardData( )
53+ {
54+ var shardsDir = new DirectoryInfo( Path.Combine(mapPath , _chunkPath));
55+
56+ var shardFiles = shardsDir.GetFiles(chunkFile_filter);
57+
58+ if (shardFiles.Length > 0) {
59+ #if DEBUG
60+ //Logger.VerboseDebug("Metadata reloading from {0} shards", shardFiles.Length);
61+ #endif
62+
63+ foreach (var shardFile in shardFiles) {
64+
65+ if (shardFile.Length < 1024) continue;
66+ var result = chunkShardRegex.Match(shardFile.Name);
67+ if (!result.Success) continue;
68+
69+ int X_chunk_pos = int.Parse(result.Groups["X"].Value);
70+ int Z_chunk_pos = int.Parse(result.Groups["Z"].Value);
71+
72+ try {
73+ using (var fileStream = shardFile.OpenRead( )) {
74+
75+ PngReader pngRead = new PngReader(fileStream);
76+ pngRead.ReadSkippingAllRows( );
77+ pngRead.End( );
78+ //Parse PNG chunks for METADATA in shard
79+ PngMetadataChunk metadataFromPng = pngRead.GetChunksList( ).GetById1(PngMetadataChunk.ID) as PngMetadataChunk;
80+ ColumnMeta columnData = metadataFromPng.ChunkMetadata;
81+ //columnData.HeightMap //Should be sane Heightmap...
82+
83+
84+
85+ }
86+
87+ } catch (PngjException someEx) {
88+ //Logger.Error("PNG Corruption file '{0}' - Reason: {1}", shardFile.Name, someEx);
89+ continue;
90+ } catch (ProtoException protoEx) {
91+ //Logger.Error("ProtoBuf invalid! file:'{0}' - Reason: {1}", shardFile.Name, protoEx);
92+ continue;
93+ }
94+ }
95+ }
96+
97+
98+ }
99+
18100 }
19101 }
--- a/ShardProcessor/ShardProcessor.csproj
+++ b/ShardProcessor/ShardProcessor.csproj
@@ -18,6 +18,7 @@
1818 <ErrorReport>prompt</ErrorReport>
1919 <WarningLevel>4</WarningLevel>
2020 <ExternalConsole>true</ExternalConsole>
21+ <Commandlineparameters>--heightmap ~/ApplicationData/vintagestory/Maps/World_19781215</Commandlineparameters>
2122 </PropertyGroup>
2223 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2324 <Optimize>true</Optimize>
@@ -28,6 +29,33 @@
2829 </PropertyGroup>
2930 <ItemGroup>
3031 <Reference Include="System" />
32+ <Reference Include="protobuf-net">
33+ <HintPath>..\Automap\VS_libs\protobuf-net.dll</HintPath>
34+ </Reference>
35+ <Reference Include="Pngcs">
36+ <HintPath>..\Automap\VS_libs\Pngcs.dll</HintPath>
37+ </Reference>
38+ <Reference Include="Newtonsoft.Json">
39+ <HintPath>..\Automap\VS_libs\Newtonsoft.Json.dll</HintPath>
40+ </Reference>
41+ <Reference Include="Automap">
42+ <HintPath>..\Automap\bin\Debug\Automap.dll</HintPath>
43+ </Reference>
44+ <Reference Include="VintagestoryAPI">
45+ <HintPath>..\Automap\VS_libs\VintagestoryAPI.dll</HintPath>
46+ </Reference>
47+ <Reference Include="VintagestoryLib">
48+ <HintPath>..\Automap\VS_libs\VintagestoryLib.dll</HintPath>
49+ </Reference>
50+ <Reference Include="VSEssentials">
51+ <HintPath>..\Automap\VS_libs\VSEssentials.dll</HintPath>
52+ </Reference>
53+ <Reference Include="VSCreativeMod">
54+ <HintPath>..\Automap\VS_libs\VSCreativeMod.dll</HintPath>
55+ </Reference>
56+ <Reference Include="VSSurvivalMod">
57+ <HintPath>..\Automap\VS_libs\VSSurvivalMod.dll</HintPath>
58+ </Reference>
3159 </ItemGroup>
3260 <ItemGroup>
3361 <Compile Include="Program.cs" />