Beispiel #1
0
        public string VerifyArchive()
        {
            string result = "";
            char   endl   = '\n';

            ProgressBar progressBar = new ProgressBar("Verify Archive");

            progressBar.SetProgressBar(0, assetDictionary.Values.Count + 1, 1);
            progressBar.Show();

            //foreach (Section_LHDR LHDR in DICT.LTOC.LHDRList)
            //    foreach (uint assetID in LHDR.assetIDlist)
            //        if (!ContainsAsset(assetID))
            //            result += $"Archive: Asset 0x{assetID.ToString("X8")} appears to be present in a layer, but it's not in the AHDR dictionary. This archive is likely unusable." + endl;

            List <Asset> ordered = assetDictionary.Values.OrderBy(f => f.assetName).ToList();

            ordered = ordered.OrderBy(f => f.assetType).ToList();

            if (!ContainsAssetWithType(AssetType.JSP))
            {
                result += $"Archive: Does not contain any JSP asset." + endl;
            }

            progressBar.PerformStep();

            foreach (Asset asset in ordered)
            {
                bool found = false;

                foreach (Section_LHDR LHDR in DICT.LTOC.LHDRList)
                {
                    foreach (uint assetID in LHDR.assetIDlist)
                    {
                        if (assetID == asset.assetID)
                        {
                            if (found == false)
                            {
                                found = true;
                            }
                            else
                            {
                                result += $"Archive: Asset {asset} is present in more than one layer. This is unexpected." + endl;
                            }
                        }
                    }
                }

                if (found == false)
                {
                    result += $"Archive: Asset {asset} appears to not be present in the AHDR dictionary, but it's not in any layer. This archive is likely unusable." + endl;
                }

                List <string> resultParam = new List <string>();
                try
                {
                    asset.Verify(ref resultParam);

                    foreach (string s in resultParam)
                    {
                        result += $"[{asset.assetType}] {asset.assetName}: " + s + endl;
                    }
                }
                catch (Exception e)
                {
                    result += $"Failed verification on [{asset.assetType}] {asset.assetName}: " + e.Message + endl;
                }

                progressBar.PerformStep();
            }

            progressBar.Close();

            return(result);
        }