Beispiel #1
0
        public void BuildBaseJenkIndex()
        {
            JenkIndex.Clear();
            foreach (RpfFile file in AllRpfs)
            {
                try
                {
                    JenkIndex.Ensure(file.Name);
                    foreach (RpfEntry entry in file.AllEntries)
                    {
                        var nlow = entry.NameLower;
                        if (string.IsNullOrEmpty(nlow))
                        {
                            continue;
                        }
                        JenkIndex.Ensure(entry.Name);
                        JenkIndex.Ensure(nlow);
                        //JenkIndex.Ensure(entry.Path);
                        //JenkIndex.Ensure(entry.Path.ToLower());
                        int ind = nlow.LastIndexOf('.');
                        if (ind > 0)
                        {
                            JenkIndex.Ensure(entry.Name.Substring(0, ind));
                            JenkIndex.Ensure(nlow.Substring(0, ind));

                            //if (ind < entry.Name.Length - 2)
                            //{
                            //    JenkIndex.Ensure(entry.Name.Substring(0, ind) + ".#" + entry.Name.Substring(ind + 2));
                            //    JenkIndex.Ensure(entry.NameLower.Substring(0, ind) + ".#" + entry.NameLower.Substring(ind + 2));
                            //}
                        }
                        if (nlow.EndsWith(".ydr") || nlow.EndsWith(".yft"))
                        {
                            var sname = nlow.Substring(0, nlow.Length - 4);
                            JenkIndex.Ensure(sname + "_lod");
                            JenkIndex.Ensure(sname + "_loda");
                            JenkIndex.Ensure(sname + "_lodb");
                        }
                        if (nlow.EndsWith(".ydd"))
                        {
                            if (nlow.EndsWith("_children.ydd"))
                            {
                                var strn = nlow.Substring(0, nlow.Length - 13);
                                JenkIndex.Ensure(strn);
                                JenkIndex.Ensure(strn + "_lod");
                                JenkIndex.Ensure(strn + "_loda");
                                JenkIndex.Ensure(strn + "_lodb");
                            }
                            var idx = nlow.LastIndexOf('_');
                            if (idx > 0)
                            {
                                var str1 = nlow.Substring(0, idx);
                                var idx2 = str1.LastIndexOf('_');
                                if (idx2 > 0)
                                {
                                    var str2 = str1.Substring(0, idx2);
                                    JenkIndex.Ensure(str2 + "_lod");
                                    var maxi = 100;
                                    for (int i = 1; i <= maxi; i++)
                                    {
                                        var str3 = str2 + "_" + i.ToString().PadLeft(2, '0');
                                        //JenkIndex.Ensure(str3);
                                        JenkIndex.Ensure(str3 + "_lod");
                                    }
                                }
                            }
                        }
                    }
                }
                catch
                {
                    //failing silently!! not so good really
                }
            }
        }
Beispiel #2
0
        public void BuildBaseJenkIndex()
        {
            JenkIndex.Clear();
            StringBuilder sb = new StringBuilder();

            foreach (RpfFile file in AllRpfs)
            {
                try
                {
                    JenkIndex.Ensure(file.Name);
                    foreach (RpfEntry entry in file.AllEntries)
                    {
                        var nlow = entry.NameLower;
                        if (string.IsNullOrEmpty(nlow))
                        {
                            continue;
                        }
                        //JenkIndex.Ensure(entry.Name);
                        //JenkIndex.Ensure(nlow);
                        int ind = nlow.LastIndexOf('.');
                        if (ind > 0)
                        {
                            JenkIndex.Ensure(entry.Name.Substring(0, ind));
                            JenkIndex.Ensure(nlow.Substring(0, ind));

                            //if (ind < entry.Name.Length - 2)
                            //{
                            //    JenkIndex.Ensure(entry.Name.Substring(0, ind) + ".#" + entry.Name.Substring(ind + 2));
                            //    JenkIndex.Ensure(entry.NameLower.Substring(0, ind) + ".#" + entry.NameLower.Substring(ind + 2));
                            //}
                        }
                        else
                        {
                            JenkIndex.Ensure(entry.Name);
                            JenkIndex.Ensure(nlow);
                        }
                        if (BuildExtendedJenkIndex)
                        {
                            if (nlow.EndsWith(".ydr"))// || nlow.EndsWith(".yft")) //do yft's get lods?
                            {
                                var sname = nlow.Substring(0, nlow.Length - 4);
                                JenkIndex.Ensure(sname + "_lod");
                                JenkIndex.Ensure(sname + "_loda");
                                JenkIndex.Ensure(sname + "_lodb");
                            }
                            if (nlow.EndsWith(".ydd"))
                            {
                                if (nlow.EndsWith("_children.ydd"))
                                {
                                    var strn = nlow.Substring(0, nlow.Length - 13);
                                    JenkIndex.Ensure(strn);
                                    JenkIndex.Ensure(strn + "_lod");
                                    JenkIndex.Ensure(strn + "_loda");
                                    JenkIndex.Ensure(strn + "_lodb");
                                }
                                var idx = nlow.LastIndexOf('_');
                                if (idx > 0)
                                {
                                    var str1 = nlow.Substring(0, idx);
                                    var idx2 = str1.LastIndexOf('_');
                                    if (idx2 > 0)
                                    {
                                        var str2 = str1.Substring(0, idx2);
                                        JenkIndex.Ensure(str2 + "_lod");
                                        var maxi = 100;
                                        for (int i = 1; i <= maxi; i++)
                                        {
                                            var str3 = str2 + "_" + i.ToString().PadLeft(2, '0');
                                            //JenkIndex.Ensure(str3);
                                            JenkIndex.Ensure(str3 + "_lod");
                                        }
                                    }
                                }
                            }
                            if (nlow.EndsWith(".sps"))
                            {
                                JenkIndex.Ensure(nlow); //for shader preset filename hashes!
                            }
                            if (nlow.EndsWith(".awc"))  //create audio container path hashes...
                            {
                                string[] parts = entry.Path.Split('\\');
                                int      pl    = parts.Length;
                                if (pl > 2)
                                {
                                    string fn    = parts[pl - 1];
                                    string fd    = parts[pl - 2];
                                    string hpath = fn.Substring(0, fn.Length - 4);
                                    if (fd.EndsWith(".rpf"))
                                    {
                                        fd = fd.Substring(0, fd.Length - 4);
                                    }
                                    hpath = fd + "/" + hpath;
                                    if (parts[pl - 3] != "sfx")
                                    {
                                    }  //no hit

                                    JenkIndex.Ensure(hpath);
                                }
                            }
                            if (nlow.EndsWith(".nametable"))
                            {
                                RpfBinaryFileEntry binfe = entry as RpfBinaryFileEntry;
                                if (binfe != null)
                                {
                                    byte[] data = file.ExtractFile(binfe);
                                    if (data != null)
                                    {
                                        sb.Clear();
                                        for (int i = 0; i < data.Length; i++)
                                        {
                                            byte c = data[i];
                                            if (c == 0)
                                            {
                                                string str = sb.ToString();
                                                if (!string.IsNullOrEmpty(str))
                                                {
                                                    string strl = str.ToLowerInvariant();
                                                    //JenkIndex.Ensure(str);
                                                    JenkIndex.Ensure(strl);

                                                    ////DirMod_Sounds_ entries apparently can be used to infer SP audio strings
                                                    ////no luck here yet though
                                                    //if (strl.StartsWith("dirmod_sounds_") && (strl.Length > 14))
                                                    //{
                                                    //    strl = strl.Substring(14);
                                                    //    JenkIndex.Ensure(strl);
                                                    //}
                                                }
                                                sb.Clear();
                                            }
                                            else
                                            {
                                                sb.Append((char)c);
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                }
                            }
                        }
                    }
                }
                catch
                {
                    //failing silently!! not so good really
                }
            }
        }