示例#1
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");
                }
            }
        }
示例#2
0
        public static void ParsMapFiles()
        {
            var mapStorage = DBReader.Read <MapRecord>("DBFilesClient\\Map.db2");

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

            Dictionary <uint, Tuple <string, int> > map_ids = new Dictionary <uint, Tuple <string, int> >();
            List <uint> maps_that_are_parents = new List <uint>();

            foreach (var record in mapStorage.Values)
            {
                map_ids[record.Id] = Tuple.Create(record.Directory, (int)record.ParentMapID);
                if (record.ParentMapID >= 0)
                {
                    maps_that_are_parents.Add((uint)record.ParentMapID);
                }
            }

            Dictionary <uint, WDTFile> wdts   = new Dictionary <uint, WDTFile>();
            Func <uint, WDTFile>       getWDT = mapId =>
            {
                var wdtFile = wdts.LookupByKey(mapId);
                if (wdtFile == null)
                {
                    string fn = $"World\\Maps\\{map_ids[mapId].Item1}\\{map_ids[mapId].Item1}";
                    bool   v1 = maps_that_are_parents.Contains(mapId);
                    bool   v2 = map_ids[mapId].Item2 != -1;

                    wdtFile = new WDTFile(fn, maps_that_are_parents.Contains(mapId));
                    wdts.Add(mapId, wdtFile);
                    if (!wdtFile.init(mapId))
                    {
                        wdts.Remove(mapId);
                        return(null);
                    }
                }

                return(wdtFile);
            };

            foreach (var pair in map_ids)
            {
                WDTFile WDT = getWDT(pair.Key);
                if (WDT != null)
                {
                    WDTFile parentWDT = pair.Value.Item2 >= 0 ? getWDT((uint)pair.Value.Item2) : null;
                    Console.Write($"Processing Map {pair.Key}\n");
                    for (uint x = 0; x < 64; ++x)
                    {
                        for (uint y = 0; y < 64; ++y)
                        {
                            bool    success = false;
                            ADTFile ADT     = WDT.GetMap(x, y);
                            if (ADT != null)
                            {
                                success = ADT.init(pair.Key, pair.Key);
                            }

                            if (!success && parentWDT != null)
                            {
                                ADTFile parentADT = parentWDT.GetMap(x, y);
                                if (parentADT != null)
                                {
                                    parentADT.init(pair.Key, (uint)pair.Value.Item2);
                                }
                            }
                        }
                        // draw progress bar
                        Console.Write($"Processing........................{(100 * (x + 1)) / 64}%\r");
                    }
                    Console.Write("\n");
                }
            }
        }
示例#3
0
        public static void ParsMapFiles()
        {
            var mapStorage = DBReader.Read <MapRecord>(1349477);

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

            Dictionary <uint, MapRecord> map_ids = new Dictionary <uint, MapRecord>();
            List <uint> maps_that_are_parents    = new List <uint>();

            foreach (var record in mapStorage.Values)
            {
                map_ids[record.Id] = record;
                if (record.ParentMapID >= 0)
                {
                    maps_that_are_parents.Add((uint)record.ParentMapID);
                }
            }

            Dictionary <uint, WDTFile> wdts   = new Dictionary <uint, WDTFile>();
            Func <uint, WDTFile>       getWDT = mapId =>
            {
                var wdtFile = wdts.LookupByKey(mapId);
                if (wdtFile == null)
                {
                    uint fileDataId = map_ids[mapId].WdtFileDataID;
                    if (fileDataId == 0)
                    {
                        return(null);
                    }

                    string directory = map_ids[mapId].Directory;

                    wdtFile = new WDTFile(fileDataId, directory, maps_that_are_parents.Contains(mapId));
                    wdts.Add(mapId, wdtFile);
                    if (!wdtFile.init(mapId))
                    {
                        wdts.Remove(mapId);
                        return(null);
                    }
                }

                return(wdtFile);
            };

            foreach (var pair in map_ids)
            {
                WDTFile WDT = getWDT(pair.Key);
                if (WDT != null)
                {
                    WDTFile parentWDT = pair.Value.ParentMapID >= 0 ? getWDT((uint)pair.Value.ParentMapID) : null;
                    Console.Write($"Processing Map {pair.Key}\n");
                    for (uint x = 0; x < 64; ++x)
                    {
                        for (uint y = 0; y < 64; ++y)
                        {
                            bool    success = false;
                            ADTFile ADT     = WDT.GetMap(x, y);
                            if (ADT != null)
                            {
                                success = ADT.init(pair.Key, pair.Key);
                            }

                            if (!success && parentWDT != null)
                            {
                                ADTFile parentADT = parentWDT.GetMap(x, y);
                                if (parentADT != null)
                                {
                                    parentADT.init(pair.Key, (uint)pair.Value.ParentMapID);
                                }
                            }
                        }
                        // draw progress bar
                        Console.Write($"Processing........................{(100 * (x + 1)) / 64}%\r");
                    }
                    Console.Write("\n");
                }
            }
        }