Ejemplo n.º 1
0
        static void ExtractMaps()
        {
            ExtractDbcFiles();
            ExtractCameraFiles();
            ExtractGameTablesFiles();

            Console.WriteLine("Extracting maps...");

            string path = $"{BaseDirectory}/maps";

            CreateDirectory(path);

            Console.WriteLine("Convert map files");
            int count = 1;

            Console.WriteLine("Loading DB2 files");
            var mapStorage = DBReader.Read <MapRecord>("DBFilesClient\\Map.db2");

            if (mapStorage == null)
            {
                Console.WriteLine("Fatal error: Invalid Map.db2 file format!");
                return;
            }

            foreach (var record in mapStorage.Values)
            {
                Console.Write($"Extract {record.Directory} ({count++}/{mapStorage.Count})                  \n");
                // Loadup map grid data
                string      storagePath = $"World\\Maps\\{record.Directory}\\{record.Directory}.wdt";
                ChunkedFile wdt         = new ChunkedFile();
                if (wdt.loadFile(CascHandler, storagePath))
                {
                    wdt_MAIN main = wdt.GetChunk("MAIN").As <wdt_MAIN>();
                    for (int y = 0; y < 64; ++y)
                    {
                        for (int x = 0; x < 64; ++x)
                        {
                            if (Convert.ToBoolean(main.adt_list[y][x].flag & 0x1))
                            {
                                storagePath = $"World\\Maps\\{record.Directory}\\{record.Directory}_{x}_{y}.adt";
                                string outputFileName = $"{path}/{record.Id:D4}_{y:D2}_{x:D2}.map";
                                MapFile.ConvertADT(CascHandler, storagePath, outputFileName, y, x, MapFile.IsDeepWaterIgnored(record.Id, y, x));
                            }
                        }
                        // draw progress bar
                        Console.Write($"Processing........................{(100 * (y + 1)) / 64}%\r");
                    }
                }
            }
            Console.WriteLine("\n");
        }
Ejemplo n.º 2
0
        static void ExtractMaps(uint build)
        {
            Console.WriteLine("Extracting maps...\n");

            string path = $"{baseDirectory}/maps";

            CreateDirectory(path);

            Console.WriteLine("Convert map files\n");
            int count = 1;

            foreach (var record in CliDB.MapStorage.Values)
            {
                Console.Write($"Extract {record.Directory} ({count++}/{CliDB.MapStorage.Count})                  \n");
                // Loadup map grid data
                string      storagePath = $"World\\Maps\\{record.Directory}\\{record.Directory}.wdt";
                ChunkedFile wdt         = new ChunkedFile();
                if (wdt.loadFile(cascHandler, storagePath))
                {
                    wdt_MAIN main = wdt.GetChunk("MAIN").As <wdt_MAIN>();
                    for (int y = 0; y < 64; ++y)
                    {
                        for (int x = 0; x < 64; ++x)
                        {
                            if (Convert.ToBoolean(main.adt_list[y][x].flag & 0x1))
                            {
                                storagePath = $"World\\Maps\\{record.Directory}\\{record.Directory}_{x}_{y}.adt";
                                string outputFileName  = $"{path}/{record.Id:D4}_{y:D2}_{x:D2}.map";
                                bool   ignoreDeepWater = MapFile.IsDeepWaterIgnored(record.Id, y, x);
                                MapFile.ConvertADT(cascHandler, storagePath, outputFileName, y, x, build, ignoreDeepWater);
                            }
                        }
                        // draw progress bar
                        Console.Write($"Processing........................{(100 * (y + 1)) / 64}%\r");
                    }
                }
            }
            Console.WriteLine("\n");
        }
Ejemplo n.º 3
0
        static void ExtractMaps()
        {
            ExtractDbcFiles();
            ExtractCameraFiles();
            ExtractGameTablesFiles();

            Console.WriteLine("Extracting maps...");

            string path = $"{BaseDirectory}/maps";

            CreateDirectory(path);

            Console.WriteLine("Convert map files");
            int count = 1;

            Console.WriteLine("Loading DB2 files");
            var mapStorage = DBReader.Read <MapRecord>(1349477);

            if (mapStorage == null)
            {
                Console.WriteLine("Fatal error: Invalid Map.db2 file format!");
                return;
            }

            foreach (var record in mapStorage.Values)
            {
                Console.Write($"Extract {record.Directory} ({count++}/{mapStorage.Count})                  \n");
                // Loadup map grid data
                ChunkedFile wdt = new ChunkedFile();
                if (wdt.loadFile(CascHandler, record.WdtFileDataID, $"WDT for map {record.Id}"))
                {
                    wdt_MPHD mphd = wdt.GetChunk("MPHD").As <wdt_MPHD>();
                    wdt_MAIN main = wdt.GetChunk("MAIN").As <wdt_MAIN>();
                    for (int y = 0; y < 64; ++y)
                    {
                        for (int x = 0; x < 64; ++x)
                        {
                            if (!Convert.ToBoolean(main.adt_list[y][x].flag & 0x1))
                            {
                                continue;
                            }

                            string outputFileName  = $"{path}/{record.Id:D4}_{y:D2}_{x:D2}.map";
                            bool   ignoreDeepWater = MapFile.IsDeepWaterIgnored(record.Id, y, x);
                            if (mphd != null && (mphd.flags & 0x200) != 0)
                            {
                                wdt_MAID maid = wdt.GetChunk("MAID").As <wdt_MAID>();
                                MapFile.ConvertADT(CascHandler, maid.adt_files[y][x].rootADT, record.MapName, outputFileName, y, x, ignoreDeepWater);
                            }
                            else
                            {
                                string storagePath = $"World\\Maps\\{record.Directory}\\{record.Directory}_{x}_{y}.adt";
                                MapFile.ConvertADT(CascHandler, storagePath, record.MapName, outputFileName, y, x, ignoreDeepWater);
                            }
                        }
                        // draw progress bar
                        Console.Write($"Processing........................{(100 * (y + 1)) / 64}%\r");
                    }
                }
            }
            Console.WriteLine("\n");
        }
Ejemplo n.º 4
0
        static void ExtractMaps(uint build)
        {
            Console.WriteLine("Extracting maps...\n");
            Console.WriteLine("Loading db2 files...\n");

            var stream = cascHandler.ReadFile("DBFilesClient\\Map.db2");

            if (stream == null)
            {
                Console.WriteLine("Unable to open file DBFilesClient\\Map.db2 in the archive\n");
                return;
            }
            mapStorage = DB6Reader.Read <MapRecord>(stream, DB6Metas.MapMeta);
            if (mapStorage == null)
            {
                Console.WriteLine("Fatal error: Invalid Map.db2 file format!\n");
                return;
            }

            stream = cascHandler.ReadFile("DBFilesClient\\LiquidType.db2");
            if (stream == null)
            {
                Console.WriteLine("Unable to open file DBFilesClient\\LiquidType.db2 in the archive\n");
                return;
            }

            liquidTypeStorage = DB6Reader.Read <LiquidTypeRecord>(stream, DB6Metas.LiquidTypeMeta);
            if (liquidTypeStorage == null)
            {
                Console.WriteLine("Fatal error: Invalid LiquidType.db2 file format!\n");
                return;
            }

            string path = $"{baseDirectory}/maps";

            CreateDirectory(path);

            Console.WriteLine("Convert map files\n");
            int count = 1;

            foreach (var map in mapStorage.Values)
            {
                Console.Write($"Extract {map.MapName} ({count}/{mapStorage.Count})                  \n");
                // Loadup map grid data
                string      storagePath = $"World\\Maps\\{map.Directory}\\{map.Directory}.wdt";
                ChunkedFile wdt         = new ChunkedFile();
                if (wdt.loadFile(cascHandler, storagePath))
                {
                    wdt_MAIN main = wdt.GetChunk("MAIN").As <wdt_MAIN>();
                    for (int y = 0; y < 64; ++y)
                    {
                        for (int x = 0; x < 64; ++x)
                        {
                            if (Convert.ToBoolean(main.adt_list[y][x].flag & 0x1))
                            {
                                storagePath = $"World\\Maps\\{map.Directory}\\{map.Directory}_{x}_{y}.adt";
                                string outputFileName = $"{path}/{map.Id:D4}_{y:D2}_{x:D2}.map";
                                MapFile.ConvertADT(cascHandler, storagePath, outputFileName, y, x, build);
                            }
                        }
                        // draw progress bar
                        Console.Write($"Processing........................{(100 * (y + 1)) / 64}%\r");
                    }
                    count++;
                }
            }
            Console.WriteLine("\n");
        }