Browse Source

Attempt to fix tex name cache again

Geoffrey Horsington 4 years ago
parent
commit
152747192c
1 changed files with 12 additions and 3 deletions
  1. 12 3
      COM3D2.CacheEditMenu/Hooks.cs

+ 12 - 3
COM3D2.CacheEditMenu/Hooks.cs

@@ -24,7 +24,7 @@ namespace COM3D2.CacheEditMenu
 
     public static class Hooks
     {
-        private const int CACHE_VERSION = 1000;
+        private const int CACHE_VERSION = 1011;
 
         private static readonly Dictionary<string, MenuInfo> infoCache = new Dictionary<string, MenuInfo>();
         private static BinaryWriter cacheWriter;
@@ -149,7 +149,7 @@ namespace COM3D2.CacheEditMenu
                 mi = mi,
                 key = menuFileName
             };
-            if (!getTexFileIDDic().TryGetValue(mi.m_nMenuFileRID, out menuInfo.texName) && texFileName != null)
+            if (texFileName != null)
                 menuInfo.texName = texFileName;
             infoCache[menuFileName] = menuInfo;
 
@@ -186,7 +186,13 @@ namespace COM3D2.CacheEditMenu
                 {
                     try
                     {
-                        if (br.ReadInt32() == CACHE_VERSION)
+                        int cacheVer = br.ReadInt32();
+                        int menuFilesCount = br.ReadInt32();
+                        int modMenuFilesCount = br.ReadInt32();
+                        
+                        if (cacheVer == CACHE_VERSION && 
+                            menuFilesCount == GameUty.MenuFiles.Length && 
+                            modMenuFilesCount == GameUty.ModOnlysMenuFiles.Length)
                         {
                             while (true)
                             {
@@ -218,6 +224,9 @@ namespace COM3D2.CacheEditMenu
             if (rebuildCache)
             {
                 cacheWriter.Write(CACHE_VERSION);
+                cacheWriter.Write(GameUty.MenuFiles.Length);
+                cacheWriter.Write(GameUty.ModOnlysMenuFiles.Length);
+                
                 foreach (var keyValuePair in infoCache)
                     keyValuePair.Value.Serialize(cacheWriter);
                 cacheWriter.Flush();