Exemplo n.º 1
0
        public static bool MultiThreadDataHash(ref string __result, byte[] ___secret_key, params BattleTechResourceType[] typesToHash)
        {
            try {
                if (DebugLog)
                {
                    Verbo("Prepare to get data hash.");
                }
                SecretKey = ___secret_key;
                if (SecretKey == null)
                {
                    throw new NullReferenceException("DataManager.secret_key is null");
                }

                int manifestCounter = 0, pos = 0;
                // For me, over half the pre-Turbine time is spent on this new BattleTechResourceLocator.  Post-Turbine it consume most time!
                BattleTechResourceLocator battleTechResourceLocator = new BattleTechResourceLocator();
                Dictionary <int, VersionManifestEntry> manifestMap  = new Dictionary <int, VersionManifestEntry>(4000); // Vanilla has 900+. Mods may adds a lot more.
                foreach (BattleTechResourceType type in typesToHash)
                {
                    foreach (VersionManifestEntry versionManifestEntry in battleTechResourceLocator.AllEntriesOfResource(type))
                    {
                        manifestMap.Add(manifestCounter++, versionManifestEntry);
                    }
                }
                battleTechResourceLocator = null;

                Dictionary <int, byte[]> hashMap = new Dictionary <int, byte[]>();
                RunHashs(manifestMap, hashMap);

                byte[] allHash = new byte[HashSize * hashMap.Count];
                for (int i = 0; i < manifestCounter; i++)
                {
                    if (!hashMap.TryGetValue(i, out byte[] hash))