/*
         * /engine/assets/shaders/uber_vs.hlsl?CAPS=_SHAD;_HASPRE;_BILLBOARD;
         */

        public static void GenerateShaderFilenames()
        {
            foreach (string filename in ShaderFilenames)
            {
                uint   secondHash           = MurmurHash2Shenmue.GetFilenameHashPlain(filename);
                string fullFilename         = MurmurHash2Shenmue.GetFullFilename(filename, secondHash);
                uint   hash                 = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(fullFilename), 0);
                FilenameDatabaseEntry entry = new FilenameDatabaseEntry(hash, secondHash, fullFilename, ArchiveTypes.Shader);
                FilenameDatabase.Add(entry);
            }

            /*
             * List<List<string>> combos = GetAllCombos(ShaderSuffixParameter);
             * foreach(List<string> parameters in combos)
             * {
             *  foreach (string fname in ShaderFilenames)
             *  {
             *      string filename = String.Format(Suffix, fname, parameters.Aggregate((i, j) => i + ";" + j));
             *
             *      uint secondHash = MurmurHash2Shenmue.GetFilenameHashPlain(filename, false);
             *      string fullFilename = MurmurHash2Shenmue.GetFullFilename(filename, secondHash);
             *      uint hash = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(fullFilename), 0);
             *      FilenameDatabase.Add(hash, secondHash, fullFilename);
             *
             *      Console.WriteLine("[{0:X8}|{1:X8}] {2}", hash, secondHash, filename);
             *  }
             * }
             */
        }
        public void GenerateFilenameDatabase(string dataFolder = "", bool inRAM = false)
        {
            FilenameDatabase.Clear();

            m_tadFiles = new List <TADFile>();
            m_tacFiles = new List <TACFile>();
            if (!String.IsNullOrEmpty(dataFolder))
            {
                List <string> archiveFiles = new List <string>();
                foreach (string file in Directory.GetFiles(dataFolder))
                {
                    if (Path.GetExtension(file) == ".tad")
                    {
                        archiveFiles.Add(Path.GetFileName(file).Replace(".tad", ""));
                    }
                }

                foreach (string archiveFile in archiveFiles)
                {
                    string  tadFilename = dataFolder + "\\" + archiveFile + ".tad";
                    string  tacFilename = dataFolder + "\\" + archiveFile + ".tac";
                    TADFile tadFile     = new TADFile(tadFilename);
                    m_tadFiles.Add(tadFile);
                    TACFile tacFile = new TACFile();

                    if (inRAM)
                    {
                        tacFile.Load(tacFilename, tadFile);
                    }
                    else
                    {
                        tacFile.Filename = tacFilename;
                        tacFile.TADFile  = tadFile;
                    }
                    m_tacFiles.Add(tacFile);
                }
            }
            int steps = 4;

            DescriptionChanged(this, new DescriptionChangedArgs("Generating audio database..."));
            ProgressChanged(this, new ProgressChangedArgs(1, steps));
            AudioDatabase.GenerateAudioFilenames();
            DescriptionChanged(this, new DescriptionChangedArgs("Generating common database..."));
            ProgressChanged(this, new ProgressChangedArgs(2, steps));
            CommonDatabase.GenerateCommonFilenames();
            DescriptionChanged(this, new DescriptionChangedArgs("Generating disk database..."));
            ProgressChanged(this, new ProgressChangedArgs(3, steps));
            DiskDatabase.GenerateDiskFilenames();
            DescriptionChanged(this, new DescriptionChangedArgs("Generating shader database..."));
            ProgressChanged(this, new ProgressChangedArgs(4, steps));
            ShaderDatabase.GenerateShaderFilenames();

            m_tadFiles.Clear();
            m_tacFiles.Clear();

            Finished(this, new FinishedArgs(true));
        }
Example #3
0
        public static List <string> GenerateAudioFilenames()
        {
            List <string> filenames = new List <string>();

            AudioFilenames.AddRange(CrawledAudioFilenames);

            for (int i = 1; i < SceneCount + 1; i++)
            {
                foreach (string lang in AudioLanguages)
                {
                    foreach (string file in AudioFilenames)
                    {
                        foreach (string extension in AudioExtensions)
                        {
                            string filename             = String.Format(AudioStreamFormatString, i, lang, file, extension);
                            uint   hash                 = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(filename, false), 0);
                            FilenameDatabaseEntry entry = new FilenameDatabaseEntry(hash, 0, filename, ArchiveTypes.Audio);
                            FilenameDatabase.Add(entry);
                        }
                    }
                }
            }
            return(filenames);
        }
        public static void GenerateCommonFilenames()
        {
            //AssetRemapping.json
            string assetRemapping = MurmurHash2Shenmue.GetFullFilename(AssetRemapping, false);

            byte[] assetRemappingBuffer    = MurmurHash2Shenmue.GetFilenameHash(assetRemapping, false);
            uint   assetRemappingFirstHash = BitConverter.ToUInt32(assetRemappingBuffer, 0);
            FilenameDatabaseEntry e        = new FilenameDatabaseEntry(assetRemappingFirstHash, 0, assetRemapping);

            FilenameDatabase.Add(e);

            bool exists = false;

            byte[] buffer = FilenameCrawler.GetBufferFromEntry(e, out exists);

            if (exists)
            {
                AssetRemappingJSON remappingStructure  = new AssetRemappingJSON(buffer);
                List <string>      BadMap              = new List <string>();
                List <string>      BruteforceFilenames = new List <string>();
                foreach (KeyValuePair <string, string> filename in remappingStructure.GenerateRMPFilenames())
                {
                    uint   hash2     = MurmurHash2Shenmue.GetFilenameHashPlain(filename.Value);
                    string fFilename = MurmurHash2Shenmue.GetFullFilename(filename.Value, hash2);
                    uint   hash1     = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(fFilename), 0);
                    FilenameDatabase.Add(hash1, hash2, filename.Key);

                    /*
                     * string[] splitted = filename.Key.Split('/');
                     * string name = splitted[splitted.Length - 1];
                     * splitted = name.Split('.');
                     * name = splitted[0];
                     * if (char.IsDigit(name[name.Length - 1]))
                     * {
                     *  string val = filename.Key.Substring(0, filename.Key.Length - 14);
                     *  if (!BadMap.Contains(val))
                     *  {
                     *      BadMap.Add(val);
                     *      BruteforceFilenames.Add(filename.Key.Substring(0, filename.Key.Length - 9));
                     *  }
                     * }
                     */
                }

                /*
                 * foreach (string filename in BruteforceFilenames)
                 * {
                 *  string[] splitted = filename.Split('.');
                 *  for (int i = 0; i < 9; i++)
                 *  {
                 *      string name = splitted[0].Substring(0, splitted[0].Length - 1);
                 *
                 *      foreach (string ext in ImageExtensions)
                 *      {
                 *          string tmp = name + i.ToString() + "." + ext;
                 *          tmp = tmp.Remove(0, 12);
                 *
                 *          uint secondHash = MurmurHash2Shenmue.GetFilenameHashPlain(tmp);
                 *          string fullFilename = MurmurHash2Shenmue.GetFullFilename(tmp, secondHash);
                 *          uint hash = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(fullFilename), 0);
                 *          FilenameDatabaseEntry entry = new FilenameDatabaseEntry(hash, secondHash, fullFilename);
                 *          FilenameDatabase.Add(entry);
                 *      }
                 *  }
                 * }
                 */
            }


            //SDTextureOverride.json
            uint   sdTextureOverrideSecondHash = MurmurHash2Shenmue.GetFilenameHashPlain(SDTextureOverride);
            string sdTextureOverride           = MurmurHash2Shenmue.GetFullFilename(SDTextureOverride, sdTextureOverrideSecondHash);
            uint   sdTextureOverrideFirstHash  = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(sdTextureOverride), 0);

            e = new FilenameDatabaseEntry(sdTextureOverrideFirstHash, sdTextureOverrideSecondHash, sdTextureOverride);
            FilenameDatabase.Add(e);

            exists = false;
            buffer = FilenameCrawler.GetBufferFromEntry(e, out exists);
            if (exists)
            {
                List <string> textures = GetSDTextureOverrideFiles(buffer);
                if (textures.Count > 0)
                {
                    foreach (string texFilename in textures)
                    {
                        uint   hash2     = MurmurHash2Shenmue.GetFilenameHashPlain(texFilename);
                        string fFilename = MurmurHash2Shenmue.GetFullFilename(texFilename, hash2);
                        uint   hash1     = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(fFilename), 0);
                        FilenameDatabase.Add(hash1, hash2, fFilename);

                        string newString = texFilename + "?usage=0";
                        hash2     = MurmurHash2Shenmue.GetFilenameHashPlain(newString);
                        fFilename = MurmurHash2Shenmue.GetFullFilename(newString, hash2);
                        hash1     = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(fFilename), 0);
                        FilenameDatabase.Add(hash1, hash2, fFilename);
                    }
                }
            }

            //Hardcoded Filenames
            foreach (string filename in HardcodedFilenames)
            {
                uint   secondHash   = MurmurHash2Shenmue.GetFilenameHashPlain(filename);
                string fullFilename = MurmurHash2Shenmue.GetFullFilename(filename, secondHash);
                uint   hash         = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(fullFilename), 0);
                FilenameDatabase.Add(hash, secondHash, fullFilename);
            }

            //Fontdefs
            foreach (string filename in GenerateFontdefFilenames())
            {
                uint   secondHash   = MurmurHash2Shenmue.GetFilenameHashPlain(filename);
                string fullFilename = MurmurHash2Shenmue.GetFullFilename(filename, secondHash);
                uint   hash         = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(fullFilename), 0);
                FilenameDatabase.Add(hash, secondHash, fullFilename);
            }

            //UI Filenames
            foreach (string filename in UIFilenames)
            {
                uint   secondHash   = MurmurHash2Shenmue.GetFilenameHashPlain(filename);
                string fullFilename = MurmurHash2Shenmue.GetFullFilename(filename, secondHash);
                uint   hash         = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(fullFilename), 0);

                FilenameDatabaseEntry entry = new FilenameDatabaseEntry(hash, secondHash, fullFilename);
                FilenameDatabase.Add(entry);

                bool   exist = false;
                byte[] buf   = FilenameCrawler.GetBufferFromEntry(entry, out exist);

                if (exist)
                {
                    List <string> images = GetImagesFromUI(buf);

                    foreach (string btn in ButtonFilenames)
                    {
                        images.Add(String.Format(SuffixUIFormat, btn, 0));
                    }

                    if (images.Count > 0)
                    {
                        foreach (string imageFilename in images)
                        {
                            uint   hash2     = MurmurHash2Shenmue.GetFilenameHashPlain(imageFilename);
                            string fFilename = MurmurHash2Shenmue.GetFullFilename(imageFilename, hash2);
                            uint   hash1     = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(fFilename), 0);
                            FilenameDatabase.Add(hash1, hash2, fFilename);
                        }
                    }
                }
            }

            //LD Filenames (LOADSCREEN.UI)
            foreach (string ldFile in GetLDFiles())
            {
                uint   hash2     = MurmurHash2Shenmue.GetFilenameHashPlain(ldFile);
                string fFilename = MurmurHash2Shenmue.GetFullFilename(ldFile, hash2);
                uint   hash1     = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(fFilename), 0);
                FilenameDatabase.Add(hash1, hash2, fFilename);
            }

            //Credits Filenames
            foreach (string creditFile in GetCreditFilenames())
            {
                uint   hash2     = MurmurHash2Shenmue.GetFilenameHashPlain(creditFile);
                string fFilename = MurmurHash2Shenmue.GetFullFilename(creditFile, hash2);
                uint   hash1     = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(fFilename), 0);
                FilenameDatabase.Add(hash1, hash2, fFilename);
            }
        }
Example #5
0
        public static void GenerateDiskFilenames()
        {
            //Swap between Shenmue 1 and 2 to improve the hash perfrmance a bit
            List <string> discCollection = new List <string>();

            //Shenmue v1.001 EU
            discCollection.Add(Resources.data["EU_D1"]);
            discCollection.Add(Resources.data["EU_D2"]);
            discCollection.Add(Resources.data["EU_D3"]);
            discCollection.Add(Resources.data["EU_PASS"]);

            //Shenmue IIx US
            discCollection.Add(Resources.data["US_2x_DVD"]);

            //Shenmue II v1.001 EU
            discCollection.Add(Resources.data["EU_2_D1"]);
            discCollection.Add(Resources.data["EU_2_D2"]);
            discCollection.Add(Resources.data["EU_2_D3"]);
            discCollection.Add(Resources.data["EU_2_PASS"]);

            //Shenmue v1.007 JAP
            discCollection.Add(Resources.data["JAP_D1"]);
            discCollection.Add(Resources.data["JAP_D2"]);
            discCollection.Add(Resources.data["JAP_D3"]);
            discCollection.Add(Resources.data["JAP_PASS"]);

            //Shenmue 2 v1.001 JAP
            discCollection.Add(Resources.data["JP_2_D1"]);
            discCollection.Add(Resources.data["JP_2_D2"]);
            discCollection.Add(Resources.data["JP_2_D3"]);
            discCollection.Add(Resources.data["JP_2_D4"]);

            //Shenmue v1.003 US
            discCollection.Add(Resources.data["US_D1"]);
            discCollection.Add(Resources.data["US_D2"]);
            discCollection.Add(Resources.data["US_D3"]);
            discCollection.Add(Resources.data["US_PASS"]);

            //Shenmue BETA v0.400
            discCollection.Add(Resources.data["B_D1"]);
            discCollection.Add(Resources.data["B_D2"]);
            discCollection.Add(Resources.data["B_D3"]);
            discCollection.Add(Resources.data["B_PASS"]);

            //What's Shemue - JP
            discCollection.Add(Resources.data["WS_D1"]);

            string fName            = "/misc/SegaLogo.wav";
            uint   fSize            = 480044;
            uint   fHash            = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(fName, false), 0);
            FilenameDatabaseEntry e = new FilenameDatabaseEntry(fHash, fName, fSize, ArchiveTypes.Disk);

            FilenameDatabase.Add(e);

            foreach (string filename in HarrierFilenames)
            {
                string hFilename            = filename.Replace("\\", "/");
                uint   fileSize             = 0;
                uint   hash                 = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(hFilename, false), 0);
                FilenameDatabaseEntry entry = new FilenameDatabaseEntry(hash, hFilename, fileSize, ArchiveTypes.Disk);
                FilenameDatabase.Add(entry);
            }

            int actCount = 3;

            for (int i = 1; i < actCount + 1; i++)
            {
                foreach (string scene in ScenarioNames)
                {
                    string filename             = String.Format(ScenarioFormat, i, scene);
                    uint   hash                 = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(filename, false), 0);
                    FilenameDatabaseEntry entry = new FilenameDatabaseEntry(hash, 0, filename, ArchiveTypes.Disk);
                    FilenameDatabase.Add(entry);
                }
            }

            //TODO: Test 99 scenes
            foreach (string scene in ScenarioNames)
            {
                string filename             = String.Format(ScenarioFormat, 99, scene);
                uint   hash                 = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(filename, false), 0);
                FilenameDatabaseEntry entry = new FilenameDatabaseEntry(hash, 0, filename, ArchiveTypes.Disk);
                FilenameDatabase.Add(entry);
            }


            foreach (var disc in discCollection)
            {
                using (StringReader reader = new StringReader(disc))
                {
                    string line = string.Empty;
                    do
                    {
                        line = reader.ReadLine();
                        if (line != null)
                        {
                            var    lineArr              = line.Split(' ');
                            string filename             = lineArr[0].Replace("\\", "/");
                            uint   fileSize             = Convert.ToUInt32(lineArr[1]);
                            uint   hash                 = BitConverter.ToUInt32(MurmurHash2Shenmue.GetFilenameHash(filename, false), 0);
                            FilenameDatabaseEntry entry = new FilenameDatabaseEntry(hash, filename, fileSize, ArchiveTypes.Disk);
                            FilenameDatabase.Add(entry);
                        }
                    } while (line != null);
                }
            }
        }