Ejemplo n.º 1
0
 public VpkPackageStreamSource(VpkDirectory directory)
 {
     _directory = directory;
     _entries = new Dictionary<string, VpkEntry>();
     _streams = new Dictionary<ushort, Stream>();
     _folders = new Dictionary<string, HashSet<string>>();
     _files = new Dictionary<string, HashSet<string>>();
     foreach (var entry in directory.GetEntries().OfType<VpkEntry>())
     {
         var fn = entry.FullName;
         _entries.Add(fn, entry);
         var split = fn.Split('/');
         var joined = "";
         for (var i = 0; i < split.Length; i++)
         {
             var sub = split[i];
             var name = joined.Length == 0 ? sub : joined + '/' + sub;
             if (i == split.Length - 1)
             {
                 // File name
                 if (!_files.ContainsKey(joined)) _files.Add(joined, new HashSet<string>());
                 _files[joined].Add(name);
             }
             else
             {
                 // Folder name
                 if (!_folders.ContainsKey(joined)) _folders.Add(joined, new HashSet<string>());
                 if (!_folders[joined].Contains(sub)) _folders[joined].Add(name);
             }
             joined = joined.Length == 0 ? sub : joined + '/' + sub;
         }
     }
 }
Ejemplo n.º 2
0
 public VpkEntry(VpkDirectory directory, string path, uint crc32, byte[] preloadBytes, ushort archiveIndex, uint entryOffset, uint entryLength)
 {
     Directory    = directory;
     Path         = path;
     Crc32        = crc32;
     PreloadData  = preloadBytes;
     ArchiveIndex = archiveIndex;
     EntryOffset  = entryOffset;
     EntryLength  = entryLength;
 }
Ejemplo n.º 3
0
 public VpkEntry(VpkDirectory directory, string path, uint crc32, byte[] preloadBytes, ushort archiveIndex, uint entryOffset, uint entryLength)
 {
     Directory = directory;
     Path = path;
     Crc32 = crc32;
     PreloadData = preloadBytes;
     ArchiveIndex = archiveIndex;
     EntryOffset = entryOffset;
     EntryLength = entryLength;
 }
Ejemplo n.º 4
0
 public VpkPackageStreamSource(VpkDirectory directory)
 {
     _directory = directory;
     _entries   = new Dictionary <string, VpkEntry>();
     _streams   = new Dictionary <ushort, Stream>();
     _folders   = new Dictionary <string, HashSet <string> >();
     _files     = new Dictionary <string, HashSet <string> >();
     foreach (var entry in directory.GetEntries().OfType <VpkEntry>())
     {
         var fn = entry.FullName;
         _entries.Add(fn, entry);
         var split  = fn.Split('/');
         var joined = "";
         for (var i = 0; i < split.Length; i++)
         {
             var sub  = split[i];
             var name = joined.Length == 0 ? sub : joined + '/' + sub;
             if (i == split.Length - 1)
             {
                 // File name
                 if (!_files.ContainsKey(joined))
                 {
                     _files.Add(joined, new HashSet <string>());
                 }
                 _files[joined].Add(name);
             }
             else
             {
                 // Folder name
                 if (!_folders.ContainsKey(joined))
                 {
                     _folders.Add(joined, new HashSet <string>());
                 }
                 if (!_folders[joined].Contains(sub))
                 {
                     _folders[joined].Add(name);
                 }
             }
             joined = joined.Length == 0 ? sub : joined + '/' + sub;
         }
     }
 }
Ejemplo n.º 5
0
 public VpkEntryStream(VpkEntry entry, VpkDirectory directory)
 {
     _entry = entry;
     _stream = directory.OpenChunk(_entry);
     _streamStart = _stream.Position;
 }
Ejemplo n.º 6
0
 public VpkEntryStream(VpkEntry entry, VpkDirectory directory)
 {
     _entry       = entry;
     _stream      = directory.OpenChunk(_entry);
     _streamStart = _stream.Position;
 }
Ejemplo n.º 7
0
        public void VmtStatsCollectorTest()
        {
            var exclude = new[]
            {
                    "ambulance"             ,
                    "backpack"              ,
                    "cable"                 ,
                    "console"               ,
                    "cp_bloodstained"       ,
                    "customcubemaps"        ,
                    "detail"                ,
                    "debug"                 ,
                    "effects"               ,
                    "engine"                ,
                    "environment maps"      ,
                    "halflife"              ,
                    "matsys_regressiontest" ,
                    "hlmv"                  ,
                    "hud"                   ,
                    "logo"                  ,
                    "maps"                  ,
                    "models"                ,
                    "overviews"             ,
                    "particle"              ,
                    "particles"             ,
                    "perftest"              ,
                    "pl_halfacre"           ,
                    "pl_hoodoo"             ,
                    "scripted"              ,
                    "shadertest"            ,
                    "sprites"               ,
                    "sun"                   ,
                    "vgui"                  ,
                    "voice"                 ,

            };

            var stats = new Dictionary<string, int>();
            using (var fs = new VpkDirectory(new FileInfo(@"F:\Steam\SteamApps\common\Team Fortress 2\tf\tf2_misc_dir.vpk")))
            {
                using (var ss = fs.GetStreamSource())
                {
                    //var vmts = fs.SearchFiles("materials", ".vmt$", true);
                    var subs = fs.GetDirectories("materials").Where(x => !exclude.Contains(x.Split('/')[1]));
                    var vmts = subs.SelectMany(x => fs.SearchFiles(x, ".vmt$", true));
                    foreach (var vmt in vmts)
                    {
                        using (var sr = new StreamReader(ss.OpenFile(vmt)))
                        {
                            var parsed = GenericStructure.Parse(sr).First();
                            var type = parsed.Name.ToLowerInvariant();
                            if (!stats.ContainsKey(type)) stats.Add(type, 0);
                            stats[type]++;
                            if (type == "refract" || type == "replacements" || type == "modulate") Console.WriteLine(type + " " + vmt);
                        }
                    }
                }
            }
            foreach (var kv in stats.OrderByDescending(x => x.Value))
            {
                Console.WriteLine(kv.Key + " - " + kv.Value);
            }
        }