OSDN Git Service

Added Protocol Buffer Header generation to shard-processor
[automap/automap.git] / ShardProcessor / Program.cs
index 800712d..e1c004b 100644 (file)
@@ -39,7 +39,7 @@ namespace ShardProcessor
                private static void ArgsDecoder(string[ ] args)
                {
                //#1 Path to maps '~/ApplicationData/vintagestory/Map/World_1234567890
                private static void ArgsDecoder(string[ ] args)
                {
                //#1 Path to maps '~/ApplicationData/vintagestory/Map/World_1234567890
-               mapPath = args[1];
+               mapPath = args.Length > 1 ? args[1] : String.Empty;
 
                //#0 Command: Heightmaps (Generation from existing shard data)
                string command = args[0];
 
                //#0 Command: Heightmaps (Generation from existing shard data)
                string command = args[0];
@@ -63,6 +63,10 @@ namespace ShardProcessor
                                Scan_OneShard( );
                        break;
 
                                Scan_OneShard( );
                        break;
 
+                       case @"--protoheader":
+                               Emit_ProtoHeader();
+                       break;
+
                default:
                        Console.WriteLine("Unrecognized Command: {0}", command);
                        break;
                default:
                        Console.WriteLine("Unrecognized Command: {0}", command);
                        break;
@@ -298,5 +302,21 @@ namespace ShardProcessor
 
                }
                }
 
                }
                }
+
+               private static void Emit_ProtoHeader( )
+               {
+               Console.WriteLine("Created Protobuf Header files.");
+                       using (var entitiesProto = File.CreateText("Entities.protoc")) 
+                       {
+                               entitiesProto.Write(Serializer.GetProto<EntitiesOfInterest>( ));
+                               entitiesProto.Flush( );
+                       }
+
+
+                       using (var pointsProto = File.CreateText("Points.protoc")) {
+                               pointsProto.Write(Serializer.GetProto<PointsOfInterest>( ));
+                               pointsProto.Flush( );
+                       }
+               }
        }
 }
        }
 }