Пример #1
0
        static void ExtractCameraFiles()
        {
            Console.WriteLine("Extracting Camera files...");
            var stream = cascHandler.ReadFile("DBFilesClient\\CinematicCamera.db2");

            if (stream == null)
            {
                Console.WriteLine("Unable to open file DBFilesClient\\CinematicCamera.db2s in the archive");
                return;
            }

            Dictionary <uint, CinematicCameraRecord> cinematicCameraStorage = DB6Reader.Read <CinematicCameraRecord>(stream, DB6Metas.CinematicCameraMeta);

            if (cinematicCameraStorage == null)
            {
                Console.WriteLine("Invalid CinematicCamera.db2 file format. Camera extract aborted.\n");
                return;
            }

            List <uint> CameraFileNames = new List <uint>();

            // get camera file list from DB2
            foreach (var record in cinematicCameraStorage.Values)
            {
                CameraFileNames.Add(record.ModelFileDataID);
            }

            Console.WriteLine($"Done! ({CameraFileNames.Count} CinematicCameras loaded)\n");

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

            CreateDirectory(path);

            // extract M2s
            uint count = 0;

            foreach (int cameraFileId in CameraFileNames)
            {
                var cameraStream = cascHandler.ReadFile(cameraFileId);
                if (cameraStream != null)
                {
                    string file = path + $"/File{cameraFileId:X8}.xxx";
                    if (!File.Exists(file))
                    {
                        FileWriter.WriteFile(cameraStream, file);
                        ++count;
                    }
                }
                else
                {
                    Console.WriteLine($"Unable to open file {$"File{cameraFileId:X8}.xxx"} in the archive: \n");
                }
            }

            Console.WriteLine($"Extracted {count} Camera files.");
        }
Пример #2
0
        static void ExtractVMaps()
        {
            Console.WriteLine("Extracting Vmap files...");

            CreateDirectory(wmoDirectory);
            File.Delete(wmoDirectory + "dir_bin");

            // Extract models, listed in GameObjectDisplayInfo.dbc
            VmapFile.ExtractGameobjectModels();

            Console.WriteLine("Read Map.dbc file... ");
            if (mapStorage == null)
            {
                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;
            }

            VmapFile.ParsMapFiles();
            Console.WriteLine("Extracting Done!");

            Console.WriteLine("Converting Vmap files...");
            CreateDirectory("./vmaps");

            TileAssembler ta = new TileAssembler(wmoDirectory, "vmaps");

            if (!ta.convertWorld2())
            {
                return;
            }

            Console.WriteLine("Converting Done!");
        }
Пример #3
0
        public static void ParsMapFiles()
        {
            var stream = Program.cascHandler.ReadFile("DBFilesClient\\Map.db2");

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

            var mapStorage = DB6Reader.Read <MapRecord>(stream, DB6Metas.MapMeta);

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

            foreach (var record in mapStorage.Values)
            {
                WDTFile WDT = new WDTFile();
                if (WDT.init($"World\\Maps\\{record.Directory}\\{record.Directory}.wdt", record.Id))
                {
                    Console.Write($"Processing Map {record.Id}\n");
                    for (uint x = 0; x < 64; ++x)
                    {
                        for (uint y = 0; y < 64; ++y)
                        {
                            ADTFile ADT = new ADTFile();
                            ADT.init($"World\\Maps\\{record.Directory}\\{record.Directory}_{x}_{y}_obj0.adt", record.Id, x, y);
                        }
                        // draw progress bar
                        Console.Write($"Processing........................{(100 * (x + 1)) / 64}%\r");
                    }
                    Console.Write("\n");
                }
            }
        }
Пример #4
0
        public static void ExtractGameobjectModels()
        {
            Console.WriteLine("Extracting GameObject models...");

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

            if (stream == null)
            {
                Console.WriteLine("Unable to open file DBFilesClient\\Map.db2 in the archive\n");
                return;
            }
            var GameObjectDisplayInfoStorage = DB6Reader.Read <GameObjectDisplayInfoRecord>(stream, DB6Metas.GameObjectDisplayInfoMeta);

            if (GameObjectDisplayInfoStorage == null)
            {
                Console.WriteLine("Fatal error: Invalid GameObjectDisplayInfo.db2 file format!\n");
                return;
            }

            string modelListPath = Program.wmoDirectory + "temp_gameobject_models";

            using (BinaryWriter binaryWriter = new BinaryWriter(File.Open(modelListPath, FileMode.Create, FileAccess.Write)))
            {
                foreach (var record in GameObjectDisplayInfoStorage.Values)
                {
                    uint fileId = record.FileDataID;
                    if (fileId == 0)
                    {
                        continue;
                    }

                    bool   result = false;
                    string header;
                    if (!GetHeaderMagic(fileId, out header))
                    {
                        continue;
                    }

                    string fileName = $"File{fileId:X8}.xxx";
                    if (header == "REVM")
                    {
                        result = ExtractSingleWmo(fileId);
                    }
                    else if (header == "MD20" || header == "MD21")
                    {
                        result = ExtractSingleModel(fileId);
                    }
                    //else
                    //ASSERT(false, "%s header: %d - %c%c%c%c", fileId, header, (header >> 24) & 0xFF, (header >> 16) & 0xFF, (header >> 8) & 0xFF, header & 0xFF);

                    if (result)
                    {
                        binaryWriter.Write(record.Id);
                        binaryWriter.Write(fileName.Length);
                        binaryWriter.WriteString(fileName);
                    }
                }
            }

            Console.WriteLine("Done!");
        }
Пример #5
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");
        }