Fix for cachefile loading due to update2.rpf being used in latest game update

This commit is contained in:
dexy 2022-04-27 08:37:34 +10:00
parent 520eee6f81
commit df77346daf

View File

@ -1199,50 +1199,16 @@ namespace CodeWalker.GameFiles
AllCacheFiles = new List<CacheDatFile>(); AllCacheFiles = new List<CacheDatFile>();
YmapHierarchyDict = new Dictionary<uint, MapDataStoreNode>(); YmapHierarchyDict = new Dictionary<uint, MapDataStoreNode>();
string cachefilepath = "common.rpf\\data\\gta5_cache_y.dat";
if (EnableDlc)
{
cachefilepath = "update\\update.rpf\\common\\data\\gta5_cache_y.dat";
}
try CacheDatFile loadCacheFile(string path, bool finalAttempt)
{ {
var maincache = RpfMan.GetFile<CacheDatFile>(cachefilepath); try
if (maincache != null)
{ {
AllCacheFiles.Add(maincache); var cache = RpfMan.GetFile<CacheDatFile>(path);
foreach (var node in maincache.AllMapNodes) if (cache != null)
{ {
if (YmapDict.ContainsKey(node.Name)) AllCacheFiles.Add(cache);
{ foreach (var node in cache.AllMapNodes)
YmapHierarchyDict[node.Name] = node;
}
else
{ } //ymap not found...
}
}
else
{
ErrorLog(cachefilepath + ": cache not loaded! Possibly an unsupported GTAV installation version.");
}
}
catch (Exception ex)
{
ErrorLog(cachefilepath + ": " + ex.ToString());
}
if (EnableDlc)
{
foreach (string dlccachefile in DlcCacheFileList)
{
try
{
var dat = RpfMan.GetFile<CacheDatFile>(dlccachefile);
if (dat == null)
{ continue; } //update\\x64\\dlcpacks\\mpspecialraces\\dlc.rpf\\x64\\data\\cacheloaderdata_dlc\\mpspecialraces_3336915258_cache_y.dat (hash of: mpspecialraces_interior_additions)
AllCacheFiles.Add(dat);
foreach (var node in dat.AllMapNodes)
{ {
if (YmapDict.ContainsKey(node.Name)) if (YmapDict.ContainsKey(node.Name))
{ {
@ -1252,78 +1218,49 @@ namespace CodeWalker.GameFiles
{ } //ymap not found... { } //ymap not found...
} }
} }
catch (Exception ex) else if (finalAttempt)
{ {
string errstr = dlccachefile + "\n" + ex.ToString(); ErrorLog(path + ": main cachefile not loaded! Possibly an unsupported GTAV installation version.");
ErrorLog(errstr);
} }
else //update\x64\dlcpacks\mpspecialraces\dlc.rpf\x64\data\cacheloaderdata_dlc\mpspecialraces_3336915258_cache_y.dat (hash of: mpspecialraces_interior_additions)
{ }
return cache;
} }
catch (Exception ex)
{
ErrorLog(path + ": " + ex.ToString());
}
return null;
}
//foreach (var dlcfile in DlcActiveRpfs)
//{ CacheDatFile maincache = null;
// foreach (RpfEntry entry in dlcfile.AllEntries) if (EnableDlc)
// { {
// try maincache = loadCacheFile("update\\update.rpf\\common\\data\\gta5_cache_y.dat", false);
// { if (maincache == null)
// if (entry.NameLower.EndsWith("_cache_y.dat")) {
// { maincache = loadCacheFile("update\\update2.rpf\\common\\data\\gta5_cache_y.dat", true);
// var dat = RpfMan.GetFile<CacheDatFile>(entry); }
// AllCacheFiles.Add(dat); }
// foreach (var node in dat.AllMapNodes) else
// { {
// if (YmapDict.ContainsKey(node.Name)) maincache = loadCacheFile("common.rpf\\data\\gta5_cache_y.dat", true);
// {
// YmapHierarchyDict[node.Name] = node;
// }
// else
// { } //ymap not found...
// }
// }
// }
// catch (Exception ex)
// {
// string errstr = entry.Path + "\n" + ex.ToString();
// ErrorLog(errstr);
// }
// }
//}
} }
//foreach (RpfFile file in RpfMan.BaseRpfs) if (EnableDlc)
//{ {
// if (file.AllEntries == null) continue; foreach (string dlccachefile in DlcCacheFileList)
// foreach (RpfEntry entry in file.AllEntries) {
// { loadCacheFile(dlccachefile, false);
// try }
// { }
// //if (entry.Name.EndsWith("_manifest.ymf"))
// //{
// // var ymf = GetFile<YmfFile>(entry);
// //}
// //else
// if (entry.NameLower.EndsWith("_cache_y.dat"))
// {
// //parse the cache dat files.
// var dat = RpfMan.GetFile<CacheDatFile>(entry);
// AllCacheFiles.Add(dat);
// foreach (var node in dat.AllMapNodes)
// {
// YmapHierarchyDict[node.Name] = node;
// }
// }
// }
// catch (Exception ex)
// {
// string errstr = entry.Path + "\n" + ex.ToString();
// ErrorLog(errstr);
// }
// }
//}
} }
private void InitArchetypeDicts() private void InitArchetypeDicts()