Exemple #1
0
        private void ResolveBaseFile(object sender, ResolveStreamEventArgs e)
        {
            var file = sender as MpqFile;

            if (file == null)
            {
                throw new InvalidOperationException();
            }

            WoWArchiveKind baseHint = WoWArchiveKind.Regular;
            string         filename = null;

            foreach (var archiveEntry in wowArchiveArray)
            {
                if (filename == null)
                {
                    if (archiveEntry.Archive == file.Archive)
                    {
                        if ((archiveEntry.Kind & WoWArchiveKind.Global) == WoWArchiveKind.Global)
                        {
                            if (file.Name.StartsWith(@"base\"))
                            {
                                baseHint = WoWArchiveKind.Base;
                                filename = file.Name.Substring(5);
                            }
                            else
                            {
                                baseHint = WoWArchiveKind.LanguagePack;
                                filename = file.Name.Substring(localePrefix.Length);
                            }
                        }
                        else
                        {
                            baseHint = archiveEntry.Kind & WoWArchiveKind.Global;
                            filename = file.Name;
                        }
                    }
                    continue;
                }

                var foundFile = FindFile(archiveEntry, filename, baseHint);

                if (foundFile != null)
                {
                    e.Stream = foundFile.Open();
                    return;
                }
            }
        }
Exemple #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));
            }
        }
 internal WoWArchiveInformation(string filename, WoWArchiveKind kind, int patchNumber = 0)
 {
     Filename = filename;
     Kind = kind;
     PatchNumber = patchNumber;
 }
Exemple #4
0
 internal WoWArchive(MpqArchive archive, WoWArchiveKind kind)
 {
     Archive = archive;
     Kind    = kind;
 }
        protected static IEnumerable<WoWArchiveInformation> GetPatchArchives(string dataPath, WoWArchiveKind archiveKind, string patchFilePattern)
        {
            var patchArchives = Directory.GetFiles(dataPath, patchFilePattern, SearchOption.TopDirectoryOnly);

            foreach (var patchArchive in patchArchives)
            {
                string archiveName = Path.GetFileName(patchArchive);
                yield return new WoWArchiveInformation(archiveName, archiveKind, DetectArchiveNumber(archiveName));
            }
        }
 /// <summary>
 /// Provides archive information for all current expansion archives.
 /// </summary>
 /// <param name="currentExpansion">The number of the current expansion, i.e. 4 for Cataclysm.</param>
 /// <param name="dataPath">Path to WoW's Data folder.</param>
 /// <param name="archiveFormat">Archive file format string used to expand the file name.</param>
 /// <param name="archiveKind"> </param>
 /// <returns>Archive information of all expansion archives iff there were currentExpansion-1 matching files, or an empty enumerable.</returns>
 protected static IEnumerable<WoWArchiveInformation> ExpansionArchivesUpTo(int currentExpansion, string dataPath, string archiveFormat, WoWArchiveKind archiveKind)
 {
     var archives = new List<WoWArchiveInformation>(currentExpansion - 1);
     for (int i = 1; i < currentExpansion; i++)
     {
         string archiveName = String.Format(CultureInfo.InvariantCulture, archiveFormat, i);
         string path = Path.Combine(dataPath, archiveName);
         if (!File.Exists(path)) return new WoWArchiveInformation[0];
         archives.Add(new WoWArchiveInformation(archiveName, archiveKind));
     }
     return archives;
 }
        /// <summary>
        /// Provides archive information for all current expansion archives.
        /// </summary>
        /// <param name="currentExpansion">The number of the current expansion, i.e. 4 for Cataclysm.</param>
        /// <param name="dataPath">Path to WoW's Data folder.</param>
        /// <param name="archiveFormat">Archive file format string used to expand the file name.</param>
        /// <param name="archiveKind"> </param>
        /// <returns>Archive information of all expansion archives iff there were currentExpansion-1 matching files, or an empty enumerable.</returns>
        protected static IEnumerable <WoWArchiveInformation> ExpansionArchivesUpTo(int currentExpansion, string dataPath, string archiveFormat, WoWArchiveKind archiveKind)
        {
            var archives = new List <WoWArchiveInformation>(currentExpansion - 1);

            for (int i = 1; i < currentExpansion; i++)
            {
                string archiveName = String.Format(CultureInfo.InvariantCulture, archiveFormat, i);
                string path        = Path.Combine(dataPath, archiveName);
                if (!File.Exists(path))
                {
                    return(new WoWArchiveInformation[0]);
                }
                archives.Add(new WoWArchiveInformation(archiveName, archiveKind));
            }
            return(archives);
        }
        protected static IEnumerable <WoWArchiveInformation> GetPatchArchives(string dataPath, WoWArchiveKind archiveKind, string patchFilePattern)
        {
            var patchArchives = Directory.GetFiles(dataPath, patchFilePattern, SearchOption.TopDirectoryOnly);

            foreach (var patchArchive in patchArchives)
            {
                string archiveName = Path.GetFileName(patchArchive);
                yield return(new WoWArchiveInformation(archiveName, archiveKind, DetectArchiveNumber(archiveName)));
            }
        }
Exemple #9
0
 internal WoWArchive(MpqArchive archive, WoWArchiveKind kind)
 {
     Archive = archive;
     Kind = kind;
 }
 internal WoWArchiveInformation(string filename, WoWArchiveKind kind, int patchNumber = 0)
 {
     Filename    = filename;
     Kind        = kind;
     PatchNumber = patchNumber;
 }