Beispiel #1
0
        static void ListChunks(FileInfo vldbFile, bool old)
        {
            byte[] fileContents = vldbFile.ReadFileFullyInflate();

            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);
                SortedDictionary <ChunkPos, int> sortedHeader = new SortedDictionary <ChunkPos, int>(header, new ChunkPosComparer(header));

                Console.WriteLine($"============== {vldbFile.Name} ==============");
                Console.WriteLine($"TOTAL AFFECTED CHUNKS: {header.Keys.Count}");
                Console.WriteLine();

                foreach (ChunkPos chunkPos in sortedHeader.Keys)
                {
                    int offset = header[chunkPos];
                    reader.BaseReader.BaseStream.Position = offset;

                    reader.BaseReader.ReadShort(); // Skip position
                    int amountLightSources = reader.ReadUInt24();

                    Console.WriteLine($"Chunk {chunkPos,10}: {amountLightSources,5} Light sources - OFFSET 0x{$"{header[chunkPos]:X}",-10}");
                }
            }
        }
Beispiel #2
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);
                }
            }
        }