Beispiel #1
0
        static void ListSingleChunk(FileInfo vldbFile, string input, bool old)
        {
            Regex regex = new Regex(@"-?[0-9]+,-?[0-9]+");

            Match match = regex.Match(input);

            if (!match.Success)
            {
                throw new Exception("Could not parse chunk coordinates");
            }

            string coords = match.Value;

            string[] parts = coords.Split(',');

            int chunkX = int.Parse(parts[0]);
            int chunkZ = int.Parse(parts[1]);

            byte[] fileContents = vldbFile.ReadFileFullyInflate();

            ChunkPos targetChunkPos = new ChunkPos(chunkX, chunkZ);

            using (VLDBReader reader = new VLDBReader(new MemoryStream(fileContents))) {
                if (!old)
                {
                    reader.verifyVldb();
                }

                int regionX = reader.BaseReader.ReadInt();
                int regionZ = reader.BaseReader.ReadInt();

                IDictionary <ChunkPos, int> header = reader.ReadHeader(regionX, regionZ);

                if (!header.ContainsKey(targetChunkPos))
                {
                    Console.WriteLine($"File does not contain chunk {targetChunkPos}");
                    return;
                }

                reader.BaseReader.BaseStream.Position = header[targetChunkPos];
                LightSource[] lightSources = reader.ReadChunk(regionX, regionZ).Item2;

                Console.WriteLine($"============== {vldbFile.Name} ==============");
                Console.WriteLine($"CHUNK {targetChunkPos}");
                Console.WriteLine($"AMOUNT LIGHT SOURCES: {lightSources.Length}");
                Console.WriteLine();

                foreach (LightSource lightSource in lightSources)
                {
                    Console.WriteLine(lightSource);
                }
            }
        }