예제 #1
0
        public void SaveAnvilChunkTest()
        {
            int width = 32;
            int depth = 32;

            int regionX = 5;
            int regionZ = 24;

            AnvilWorldProvider anvil = new AnvilWorldProvider(@"D:\Development\Worlds\KingsLanding\");

            anvil.Initialize();
            Stopwatch sw = new Stopwatch();

            sw.Start();
            for (int x = 0; x < 32; x++)
            {
                for (int z = 0; z < 32; z++)
                {
                    int cx = (width * regionX) + x;
                    int cz = (depth * regionZ) + z;

                    ChunkCoordinates coordinates = new ChunkCoordinates(cx, cz);
                    ChunkColumn      chunk       = anvil.GenerateChunkColumn(coordinates, false);
                    Assert.NotNull(chunk);
                }
            }

            Console.WriteLine("Read {0} chunks in {1}ms", anvil.NumberOfCachedChunks(), sw.ElapsedMilliseconds);

            sw.Restart();

            anvil.SaveChunks();

            Console.WriteLine("Saved {0} chunks in {1}ms", anvil.NumberOfCachedChunks(), sw.ElapsedMilliseconds);


            for (int x = 0; x < 32; x++)
            {
                for (int z = 0; z < 32; z++)
                {
                    int cx = (width * regionX) + x;
                    int cz = (depth * regionZ) + z;

                    ChunkCoordinates coordinates = new ChunkCoordinates(cx, cz);
                    anvil.GenerateChunkColumn(coordinates, false);
                }
            }
        }
예제 #2
0
        public void OffsetFileExistPerformance()
        {
            var basePath = @"D:\Development\Repos\MapsPE\hub";
            var provider = new AnvilWorldProvider(basePath);

            provider.Initialize();

            var coordinates = new ChunkCoordinates(new PlayerLocation(-1021, 18, 2385));

            for (int i = 0; i < 10000; i++)
            {
                var chunk = provider.GenerateChunkColumn(coordinates);

                int rx = coordinates.X >> 5;
                int rz = coordinates.Z >> 5;

                string filePath = Path.Combine(basePath, string.Format(@"region{2}r.{0}.{1}.mca", rx, rz, Path.DirectorySeparatorChar));
                Assert.True(File.Exists(filePath));

                Assert.AreEqual(-2, rx, "X");
                Assert.AreEqual(4, rz, "Z");
                Assert.IsNull(chunk, $"Region Coord: {rx}, {rz}");
                //Assert.IsNotNull(chunk);
            }
        }
예제 #3
0
        public void SaveOneAnvilChunkTest()
        {
            int width = 32;
            int depth = 32;

            int cx = (width * 4) + 3;
            int cz = (depth * 25) + 0;

            AnvilWorldProvider anvil = new AnvilWorldProvider(@"D:\Development\Worlds\KingsLanding\");

            anvil.Initialize();

            ChunkCoordinates coordinates = new ChunkCoordinates(cx, cz);
            ChunkColumn      chunk       = anvil.GenerateChunkColumn(coordinates);

            Assert.NotNull(chunk);

            Stopwatch sw = new Stopwatch();

            sw.Start();

            anvil.SaveChunks();

            Assert.Less(sw.ElapsedMilliseconds, 1);
        }