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,19 +1199,16 @@ namespace CodeWalker.GameFiles
AllCacheFiles = new List<CacheDatFile>();
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";
}
CacheDatFile loadCacheFile(string path, bool finalAttempt)
{
try
{
var maincache = RpfMan.GetFile<CacheDatFile>(cachefilepath);
if (maincache != null)
var cache = RpfMan.GetFile<CacheDatFile>(path);
if (cache != null)
{
AllCacheFiles.Add(maincache);
foreach (var node in maincache.AllMapNodes)
AllCacheFiles.Add(cache);
foreach (var node in cache.AllMapNodes)
{
if (YmapDict.ContainsKey(node.Name))
{
@ -1221,109 +1218,49 @@ namespace CodeWalker.GameFiles
{ } //ymap not found...
}
}
else
else if (finalAttempt)
{
ErrorLog(cachefilepath + ": cache not loaded! Possibly an unsupported GTAV installation version.");
ErrorLog(path + ": main cachefile not loaded! Possibly an unsupported GTAV installation version.");
}
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(cachefilepath + ": " + ex.ToString());
ErrorLog(path + ": " + ex.ToString());
}
return null;
}
CacheDatFile maincache = null;
if (EnableDlc)
{
maincache = loadCacheFile("update\\update.rpf\\common\\data\\gta5_cache_y.dat", false);
if (maincache == null)
{
maincache = loadCacheFile("update\\update2.rpf\\common\\data\\gta5_cache_y.dat", true);
}
}
else
{
maincache = loadCacheFile("common.rpf\\data\\gta5_cache_y.dat", true);
}
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))
{
YmapHierarchyDict[node.Name] = node;
}
else
{ } //ymap not found...
loadCacheFile(dlccachefile, false);
}
}
catch (Exception ex)
{
string errstr = dlccachefile + "\n" + ex.ToString();
ErrorLog(errstr);
}
}
//foreach (var dlcfile in DlcActiveRpfs)
//{
// foreach (RpfEntry entry in dlcfile.AllEntries)
// {
// try
// {
// if (entry.NameLower.EndsWith("_cache_y.dat"))
// {
// var dat = RpfMan.GetFile<CacheDatFile>(entry);
// AllCacheFiles.Add(dat);
// foreach (var node in dat.AllMapNodes)
// {
// if (YmapDict.ContainsKey(node.Name))
// {
// 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 (file.AllEntries == null) continue;
// foreach (RpfEntry entry in file.AllEntries)
// {
// 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()