예제 #1
0
파일: Wdt.cs 프로젝트: catontheway/Tools-3
 public WDTFile(string mapName, bool cache)
 {
     _mapName = mapName;
     if (cache)
     {
         _adtCache = new ADTFile[64][];
         for (var i = 0; i < 64; ++i)
         {
             _adtCache[i] = new ADTFile[64];
         }
     }
 }
예제 #2
0
파일: Wdt.cs 프로젝트: Sylvamore/Tools
        public WDTFile(uint fileDataId, string mapName, bool cache)
        {
            _fileStream = Program.CascHandler.OpenFile((int)fileDataId);
            _mapName    = mapName;

            if (cache)
            {
                _adtCache = new ADTFile[64][];
                for (var i = 0; i < 64; ++i)
                {
                    _adtCache[i] = new ADTFile[64];
                }
            }
        }
예제 #3
0
파일: Wdt.cs 프로젝트: catontheway/Tools-3
        public ADTFile GetMap(uint x, uint y)
        {
            if (!(x >= 0 && y >= 0 && x < 64 && y < 64))
            {
                return(null);
            }

            if (_adtCache != null && _adtCache[x][y] != null)
            {
                return(_adtCache[x][y]);
            }

            string  name = $"{_mapName}_{x}_{y}_obj0.adt";
            ADTFile adt  = new ADTFile(name, _adtCache != null);

            if (_adtCache != null)
            {
                _adtCache[x][y] = adt;
            }
            return(adt);
        }
예제 #4
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");
                }
            }
        }
예제 #5
0
파일: Wdt.cs 프로젝트: Sylvamore/Tools
        public ADTFile GetMap(uint x, uint y)
        {
            if (!(x >= 0 && y >= 0 && x < 64 && y < 64))
            {
                return(null);
            }

            if (_adtCache != null && _adtCache[x][y] != null)
            {
                return(_adtCache[x][y]);
            }

            if (!Convert.ToBoolean(_adtInfo.Data[y][x].Flag & 1))
            {
                return(null);
            }

            ADTFile adt;
            string  name = $"World\\Maps\\{_mapName}\\{_mapName}_{x}_{y}_obj0.adt";

            if ((_header.Flags & 0x200) != 0)
            {
                adt = new ADTFile(_adtFileDataIds.Data[y][x].Obj0ADT, _adtCache != null);
            }
            else
            {
                adt = new ADTFile(name, _adtCache != null);
            }

            if (_adtCache != null)
            {
                _adtCache[x][y] = adt;
            }

            return(adt);
        }
예제 #6
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");
                }
            }
        }
예제 #7
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");
                }
            }
        }