Represents an archive in a World of Warcraft installation.
Пример #1
0
        /// <summary>Creates a MpqFileSystem using the specified language pack.</summary>
        /// <param name="languagePack">The language pack.</param>
        /// <param name="enforceCultureCheck">if set to <c>true</c> the culture checks will be enforced.</param>
        /// <param name="shouldParseListFiles">if set to <c>true</c> the list files will be parsed.</param>
        /// <returns>The newly created MpqFileSystem.</returns>
        public WoWMpqFileSystem CreateFileSystem(WoWLanguagePack languagePack, bool enforceCultureCheck, bool shouldParseListFiles)
        {
            if (languagePack == null)
            {
                throw new ArgumentNullException("languagePack");
            }
            if (languagePack.WoWInstallation != this)
            {
                throw new ArgumentException();
            }
#pragma warning disable 618
            if (enforceCultureCheck && installationKind == WoW.WoWInstallationKind.Classic && languagePack.DatabaseFieldIndex < 0)
#pragma warning restore 618
            {
                throw new CultureNotSupportedException(languagePack.Culture);
            }

            // Process the archive list
            var archiveInformationList = new List <WoWArchiveInformation>();
            archiveInformationList.AddRange(archiveArray);
            archiveInformationList.AddRange(languagePack.Archives);
            archiveInformationList.Sort(WoWArchiveInformationComparer.Default);
            archiveInformationList.Reverse();

            // Load the various archives and create the file system
            var wowArchiveArray = new WoWArchive[archiveInformationList.Count];

            for (int i = 0; i < wowArchiveArray.Length; i++)
            {
                var archiveInformation = archiveInformationList[i];

                var path = (archiveInformation.Kind & WoWArchiveKind.Global) == WoWArchiveKind.LanguagePack
                    ? languagePack.Path : DataPath;
                wowArchiveArray[i] = new WoWArchive(new MpqArchive(IOPath.Combine(path, archiveInformation.Filename), shouldParseListFiles), archiveInformation.Kind);
            }

            return(new WoWMpqFileSystem(wowArchiveArray, IOPath.GetFileName(languagePack.Path)));
        }
Пример #2
0
        private MpqFile FindFile(WoWArchive archiveEntry, string filename, WoWArchiveKind baseHint = WoWArchiveKind.Regular)
        {
            if ((archiveEntry.Kind & WoWArchiveKind.Global) == WoWArchiveKind.Global)
            {
                string firstTry, secondTry;

                if ((baseHint & WoWArchiveKind.Global) == WoWArchiveKind.Base)
                {
                    firstTry  = @"base\";
                    secondTry = localePrefix;
                }
                else
                {
                    firstTry  = localePrefix;                    // Always search in the locale first if not asked otherwise…
                    secondTry = @"base\";
                }

                return(archiveEntry.Archive.FindFile(firstTry + filename) ?? archiveEntry.Archive.FindFile(secondTry + filename));
            }
            else
            {
                return(archiveEntry.Archive.FindFile(filename));
            }
        }