Beispiel #1
0
        static DBC()
        {
            CurrencyTypes               = new DBCStorage<CurrencyTypesEntry>();
            Spell                       = new DBCStorage<SpellEntry>();
            SpellEffect                 = new DBCStorage<SpellEffectEntry>();
            SpellTargetRestrictions     = new DBCStorage<SpellTargetRestrictionsEntry>();
            SpellAuraRestrictions       = new DBCStorage<SpellAuraRestrictionsEntry>();
            SpellCooldowns              = new DBCStorage<SpellCooldownsEntry>();
            SpellCategories             = new DBCStorage<SpellCategoriesEntry>();
            SpellShapeshift             = new DBCStorage<SpellShapeshiftEntry>();
            SpellAuraOptions            = new DBCStorage<SpellAuraOptionsEntry>();
            SpellLevels                 = new DBCStorage<SpellLevelsEntry>();
            SpellClassOptions           = new DBCStorage<SpellClassOptionsEntry>();
            SpellCastingRequirements    = new DBCStorage<SpellCastingRequirementsEntry>();
            SpellPower                  = new DBCStorage<SpellPowerEntry>();
            SpellInterrupts             = new DBCStorage<SpellInterruptsEntry>();
            SpellEquippedItems          = new DBCStorage<SpellEquippedItemsEntry>();
            SpellRadius                 = new DBCStorage<SpellRadiusEntry>();
            SpellCastTimes              = new DBCStorage<SpellCastTimesEntry>();
            SpellDifficulty             = new DBCStorage<SpellDifficultyEntry>();
            SpellRange                  = new DBCStorage<SpellRangeEntry>();
            SpellReagents               = new DBCStorage<SpellReagentsEntry>();
            SpellDuration               = new DBCStorage<SpellDurationEntry>();
            SkillLineAbility            = new DBCStorage<SkillLineAbilityEntry>();
            SkillLine                   = new DBCStorage<SkillLineEntry>();
            ScreenEffect                = new DBCStorage<ScreenEffectEntry>();
            OverrideSpellData           = new DBCStorage<OverrideSpellDataEntry>();
            ItemClass                   = new DBCStorage<ItemClassEntry>();
            SpellShapeshiftForm         = new DBCStorage<SpellShapeshiftFormEntry>();
            SpellDispelType             = new DBCStorage<SpellDispelTypeEntry>();

            SpellEffects                = new Dictionary<uint, Dictionary<uint, SpellEffectEntry>>();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Version = Assembly.GetExecutingAssembly().GetName().Version;
            SetDefaultTitle();
            PrintHeader();

            if (!DBCExtractor.ExtractDBC())
            {
                Console.WriteLine("Unable to extract DBC files, exiting...");
                Console.ReadLine();
                Environment.Exit(0);
            }

            if (!DBCStorage.Initialize())
            {
                Console.WriteLine("Unable to initialize DBC Storage, exiting...");
                Console.ReadLine();
                Environment.Exit(0);
            }

            List <string> WDTFiles;

            if (!WDTExtractor.ExtractWDTFiles(out WDTFiles))
            {
                Console.WriteLine("Unable to extract WDT files, exiting...");
                Console.ReadLine();
                Environment.Exit(0);
            }

            // For test only, extract only Azeroth.
            // TODO: We need to process, build map files, and release memory ASAP.
            // Right now, loading all data we are parsing would result in around 10gb.

            //Begin loading all wdt information.
            if (!Globals.LoadAsync)
            {
                foreach (var wdt in WDTFiles)
                {
                    var map = new CMapObj(wdt, null);
                    map.LoadData();
                    LoadedMaps.Add(map);
                    break;
                }
            }
            else
            {
                foreach (var wdt in WDTFiles)
                {
                    AsyncMapLoader loadMapTask = new AsyncMapLoader(wdt);
                    loadMapTask.OnMapLoaded += OnMapLoaded;
                    loadMapTask.RunWorkerAsync();
                    break;
                }
            }

            Console.ReadLine();
        }
Beispiel #3
0
        public static bool ExtractWDTFiles(out Dictionary <DBCMap, string> wdtFiles)
        {
            wdtFiles = new Dictionary <DBCMap, string>();

            try
            {
                Logger.Notice("Extracting WDT files...");
                // Clean up output directory if neccesary.
                if (Directory.Exists(OutputDirectory))
                {
                    Directory.Delete(OutputDirectory, true);
                }
                Directory.CreateDirectory(OutputDirectory);

                if (!Directory.Exists(Paths.InputMapsPath))
                {
                    Logger.Error($"Unable to locate {Paths.InputMapsPath}, please check Config.txt and set a proper installation path.");
                    return(false);
                }

                foreach (var dir in Directory.EnumerateDirectories(Paths.InputMapsPath))
                {
                    var folderMapName = Path.GetFileName(dir);
                    if (DBCStorage.TryGetMapByName(folderMapName, out DBCMap map))
                    {
                        foreach (var file in Directory.EnumerateFiles(dir))
                        {
                            if (file.Contains("wdt"))
                            {
                                var filePath = Paths.Combine(dir, Path.GetFileName(file));
                                if (ExtractWDT(filePath, out string outputWdtPath))
                                {
                                    wdtFiles.Add(map, outputWdtPath);
                                }
                            }
                        }
                    }
                    else
                    {
                        Logger.Warning($"Unable to locate DBC map for: {folderMapName}");
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message);
            }

            return(false);
        }
Beispiel #4
0
        public IEnumerable <string> GetAreaNames()
        {
            HashSet <uint> areas = new HashSet <uint>();

            for (int x = 0; x < Constants.TileSize; x++)
            {
                for (int y = 0; y < Constants.TileSize; y++)
                {
                    var areaID = Tiles[x, y].area;
                    if (!areas.Contains(areaID))
                    {
                        if (DBCStorage.TryGetAreaByAreaNumber(areaID, out AreaTable areaTable))
                        {
                            yield return(areaTable.AreaName_enUS);
                        }
                        else
                        {
                            yield return($"Unknown area {areaID}");
                        }
                        areas.Add(areaID);
                    }
                }
            }
        }
Beispiel #5
0
        public static DBCStorage <T> Load <T>(bool dbc) where T : class, new()
        {
            string fileName = string.Format("{0}.{1}", typeof(T).Name.Replace("Entry", ""), dbc ? "dbc" : "db2");
            string path     = Path.Combine(DbFilePath, fileName);

            if (!File.Exists(path))
            {
                throw new FileNotFoundException("File " + path + " not found!");
            }

            DBCStorage <T> storage = new DBCStorage <T>();

            if (!dbc)
            {
                storage = new DB2Storage <T>();
            }

            using (FileStream stream = new FileStream(path, FileMode.Open))
            {
                storage.Load(stream);
            }

            return(storage);
        }
Beispiel #6
0
        public void LoadData()
        {
            // File version, must be 18.
            Console.WriteLine("Reading file version...");
            if (!ReadMVER())
            {
                return;
            }

            // MapHeader
            Console.WriteLine("Reading map header...");
            if (!ReadMPHD())
            {
                return;
            }

            // Map tile table. Needs to contain 64x64 = 4096 entries of sizeof(SMAreaInfo)
            Console.WriteLine("Reading MAIN section...");
            if (!ReadMAIN())
            {
                return;
            }

            // Filenames Doodads. Zero-terminated strings with complete paths to models.
            Console.WriteLine("Reading Doodads file names...");
            if (!ReadMDNM())
            {
                return;
            }

            // Filenames WMOS. Zero-terminated strings with complete paths to models.
            Console.WriteLine("Reading WMOS file names...");
            if (!ReadMONM())
            {
                return;
            }

            // Only one instance is possible. It is usually used by WMO based maps which contain no ADT parts with the exception of RazorfenDowns.
            // If this chunk exists, the client marks the map as a dungeon and uses absolute positioning for lights.
            Console.WriteLine("Reading MODF section...");
            if (!ReadMODF())
            {
                return;
            }

            // The start of what is now the ADT files.
            Console.WriteLine($"Reading {SMAreaChunks.Length} Area chunks...");
            if (!LoadMapAreaChunks())
            {
                return;
            }

            Console.WriteLine();
            Console.WriteLine($"Map information:");
            Console.WriteLine($"ADT Version: {ADTVersion}");
            Console.Write(SMOHeader.ToString());
            Console.WriteLine($"DoodadsNames: {DoodadsNames.Count}");
            Console.WriteLine($"MapObjectsNames: {MapObjectsNames.Count}");
            Console.WriteLine($"SMAreaChunks: {SMAreaChunks.Length}");
            Console.WriteLine($"MapAreaChunks: {MapAreaChunks.Count}");

            Console.WriteLine();
            Console.WriteLine("Found data for the following Areas:");
            foreach (var area in GetUniqueAreaIDs())
            {
                if (DBCStorage.TryGetByAreaNumber(area, out AreaTable table))
                {
                    Console.WriteLine($" AreaNumber: {table.AreaNumber}\tAreaName: {table.AreaName_enUS}");
                }
                else
                {
                    Console.WriteLine($" No information found for Area id: {area}");
                }
            }


            Console.WriteLine("Map loading complete.");
            OnRead -= OnBinaryRead;
            Worker  = null;
        }
Beispiel #7
0
        public SMChunk(byte[] chunk) : base(new MemoryStream(chunk))
        {
            flags           = this.ReadUInt32();
            indexX          = this.ReadUInt32();
            indexY          = this.ReadUInt32();
            radius          = this.ReadSingle();
            nLayers         = this.ReadUInt32();
            nDoodadRefs     = this.ReadUInt32();
            offsHeight      = this.ReadUInt32(); // MCVT
            offsNormal      = this.ReadUInt32(); // MCNR
            offsLayer       = this.ReadUInt32(); // MCLY
            offsRefs        = this.ReadUInt32(); // MCRF
            offsAlpha       = this.ReadUInt32(); // MCAL
            sizeAlpha       = this.ReadUInt32();
            offsShadow      = this.ReadUInt32(); // MCSH
            sizeShadow      = this.ReadUInt32();
            area            = this.ReadUInt32(); // in alpha: zone id (4) sub zone id (4)
            nMapObjRefs     = this.ReadUInt32();
            holes_low_res   = this.ReadUInt16();
            padding         = this.ReadUInt16();
            predTex         = this.ReadBytes(16); //It is used to determine which detail doodads to show.
            noEffectDoodad  = this.ReadBytes(8);
            offsSndEmitters = this.ReadUInt32();  // MCSE
            nSndEmitters    = this.ReadUInt32();
            offsLiquid      = this.ReadUInt32();  // MCLQ

            unused = this.ReadBytes(24);

            HeaderOffsetEnd = this.BaseStream.Position;

            // MCVT begin right after header.
            BuildSubMCVT(this, offsHeight);

            if (Globals.Verbose)
            {
                if (!MCVTS.Contains(area))
                {
                    if (DBCStorage.TryGetByAreaNumber(area, out AreaTable table))
                    {
                        Console.WriteLine($"Built MCVT SubChunk for Area: {table.AreaName_enUS}");
                    }
                    MCVTS.Add(area);
                }
            }

            if (offsNormal > 0) //Has MCNR SubChunk
            {
                BuildSubMCNR(this, offsNormal);

                if (Globals.Verbose)
                {
                    if (!MCNRS.Contains(area))
                    {
                        if (DBCStorage.TryGetByAreaNumber(area, out AreaTable table))
                        {
                            Console.WriteLine($"Built MCNR SubChunk for Area: {table.AreaName_enUS}");
                        }
                        MCNRS.Add(area);
                    }
                }
            }
        }
Beispiel #8
0
        private static void StartProcess()
        {
            Version = Assembly.GetExecutingAssembly().GetName().Version;
            SetDefaultTitle();
            PrintHeader();

            try
            {
                // Extract Map.dbc and AreaTable.dbc
                if (!DBCExtractor.ExtractDBC())
                {
                    Logger.Error("Unable to extract DBC files, exiting...");
                    Console.ReadLine();
                    Environment.Exit(0);
                }

                // Load both files in memory.
                if (!DBCStorage.Initialize())
                {
                    Logger.Error("Unable to initialize DBC Storage, exiting...");
                    Console.ReadLine();
                    Environment.Exit(0);
                }

                // Extract available maps inside MPQ
                Dictionary <DBCMap, string> WDTFiles;
                if (!WDTExtractor.ExtractWDTFiles(out WDTFiles))
                {
                    Logger.Error("Unable to extract WDT files, exiting...");
                    Console.ReadLine();
                    Environment.Exit(0);
                }

                // Flush .map files output dir.
                Directory.Delete(Paths.OutputMapsPath, true);

                //Begin parsing adt files and generate .map files.
                foreach (var entry in WDTFiles)
                {
                    using (CMapObj map = new CMapObj(entry.Key, entry.Value)) // Key:DbcMap Value:FilePath
                    {
                        MapFilesGenerator.GenerateMapFiles(map);
                        LoadedMaps.Add(entry.Key);
                    }

                    GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, true);
                }

                WDTFiles?.Clear();
                Console.WriteLine();
                Logger.Success("Process Complete, press any key to exit...");
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message);
                Logger.Error(ex.StackTrace);
            }
            finally
            {
                IsRunning = false;
            }
        }
 public void Load()
 {
     _storage = DBFileLoader.Load<ItemExtendedCostEntry>(false);
 }
Beispiel #10
0
 public void Load()
 {
     _storage = DBFileLoader.Load <ItemExtendedCostEntry>(false);
 }