Merge 03165284b233b1f0c3b9905864b74d7b351dd637 into 5db512287cb735c43eddae6cf57a0053250758c8
This commit is contained in:
commit
01ed9995d6
@ -70,6 +70,10 @@ namespace big
|
||||
if (!m_data)
|
||||
return false;
|
||||
|
||||
LOG(VERBOSE) << "Checking if cache is up-to-date for " << m_cache_file.get_path().filename() << "\n\t\t"
|
||||
<< "Cache Version " << (m_cache_version == m_cache_header.m_cache_version ? "match" : "mismatch") << " (file: " << m_cache_header.m_cache_version << ", menu: " << m_cache_version << ")\n\t\t"
|
||||
<< "Game EXE Size " << (file_version == m_cache_header.m_file_version ? "match" : "mismatch") << " (file: " << m_cache_header.m_file_version << ", game: " << file_version << ")";
|
||||
|
||||
return m_cache_version == m_cache_header.m_cache_version && file_version == m_cache_header.m_file_version;
|
||||
}
|
||||
|
||||
|
@ -152,6 +152,13 @@ namespace big
|
||||
|
||||
const auto file_version = memory::module("GTA5.exe").timestamp();
|
||||
|
||||
const auto ped_count = m_peds_cache.data_size() / sizeof(ped_item);
|
||||
const auto vehicle_count = m_vehicles_cache.data_size() / sizeof(vehicle_item);
|
||||
if (ped_count == 0 || vehicle_count == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return m_peds_cache.up_to_date(file_version) && m_vehicles_cache.up_to_date(file_version) && m_weapons_cache.up_to_date(file_version);
|
||||
}
|
||||
|
||||
|
@ -16,30 +16,19 @@ namespace big
|
||||
m_wrapper_call_back.push_back(cb);
|
||||
}
|
||||
|
||||
static bool safe_open_pack_file(rage::fiPackfile& packfile, const std::u8string& path)
|
||||
static bool safe_open_pack_file(rage::fiPackfile& packfile, const std::string& path)
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
__try
|
||||
{
|
||||
success = packfile.OpenPackfile(reinterpret_cast<const char*>(path.c_str()), true, 0, 0);
|
||||
}
|
||||
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return success;
|
||||
return packfile.OpenPackfile(path.c_str(), true, 0, 0);
|
||||
}
|
||||
|
||||
void yim_fipackfile::traverse_rpf_file(const std::u8string& path, int depth)
|
||||
void yim_fipackfile::traverse_rpf_file(const std::string& path, int depth)
|
||||
{
|
||||
std::string mount_path = std::format("temp{}:/", depth);
|
||||
|
||||
rage::fiPackfile packfile;
|
||||
if (!safe_open_pack_file(packfile, path))
|
||||
{
|
||||
LOG(INFO) << "Failed opening " << reinterpret_cast<const char*>(path.c_str());
|
||||
LOG(INFO) << "Failed opening " << path;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -50,14 +39,15 @@ namespace big
|
||||
const auto files = rpf_wrapper.get_file_paths();
|
||||
for (const auto& file : files)
|
||||
{
|
||||
if (file.extension() == ".rpf")
|
||||
if (std::filesystem::path(file).extension() == ".rpf")
|
||||
{
|
||||
if (auto handle = ((rage::fiDevice*)&packfile)->Open(reinterpret_cast<const char*>(file.u8string().c_str()), true))
|
||||
if (auto handle = ((rage::fiDevice*)&packfile)->Open(file.c_str(), true))
|
||||
{
|
||||
uint32_t encryption_type{};
|
||||
((rage::fiDevice*)&packfile)->Seek(handle, 12, 0);
|
||||
((rage::fiDevice*)&packfile)->Read(handle, &encryption_type, 4);
|
||||
((rage::fiDevice*)&packfile)->Close(handle);
|
||||
rage::fiDevice* device = &packfile;
|
||||
device->Seek(handle, 12, 0);
|
||||
device->Read(handle, &encryption_type, 4);
|
||||
device->Close(handle);
|
||||
|
||||
if (encryption_type == 0xFFFFFF9)
|
||||
continue; // skip AES encrypted RPFs
|
||||
@ -65,12 +55,12 @@ namespace big
|
||||
// OPEN / CFXP
|
||||
if (encryption_type == 0x4E45504F || encryption_type == 0x50584643)
|
||||
{
|
||||
LOG(INFO) << "Modded RPF, skipping " << reinterpret_cast<const char*>(file.u8string().c_str());
|
||||
LOG(INFO) << "Modded RPF, skipping " << file;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
traverse_rpf_file(file.u8string(), depth + 1);
|
||||
traverse_rpf_file(file, depth + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -99,7 +89,8 @@ namespace big
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(WARNING) << "game_folder variable is not directory " << reinterpret_cast<const char*>(game_folder.u8string().c_str());
|
||||
LOG(WARNING) << "game_folder variable is not directory "
|
||||
<< reinterpret_cast<const char*>(game_folder.u8string().c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -127,33 +118,42 @@ namespace big
|
||||
LOG(WARNING) << "Failed printing GTA install directory: " << e.what();
|
||||
}
|
||||
|
||||
for (const auto& entry : std::filesystem::recursive_directory_iterator(gta_folder, std::filesystem::directory_options::skip_permission_denied))
|
||||
// Ensure current_path is gta folder.
|
||||
std::filesystem::current_path(gta_folder);
|
||||
|
||||
for (const auto& entry : std::filesystem::recursive_directory_iterator(std::filesystem::current_path(), std::filesystem::directory_options::skip_permission_denied))
|
||||
{
|
||||
if (!entry.is_regular_file())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto rel_path = std::filesystem::relative(entry.path());
|
||||
const auto utf8_path = string_conversions::utf_16_to_code_page(CP_UTF8, entry.path().wstring());
|
||||
|
||||
LOG(VERBOSE) << "Game file path: " << utf8_path;
|
||||
|
||||
if (entry.path().empty())
|
||||
continue;
|
||||
|
||||
const auto rel_path = std::filesystem::relative(utf8_path);
|
||||
|
||||
const auto utf8_rel_path = string_conversions::utf_16_to_code_page(CP_UTF8, rel_path.wstring());
|
||||
LOG(VERBOSE) << "Game file path relative: " << utf8_rel_path;
|
||||
|
||||
if (rel_path.empty())
|
||||
continue;
|
||||
|
||||
const auto utf8_path = string_conversions::utf_16_to_code_page(CP_UTF8, entry.path().native());
|
||||
|
||||
if (utf8_path.empty())
|
||||
continue;
|
||||
|
||||
if (utf8_path.contains("mods"))
|
||||
if (utf8_rel_path.contains("mods"))
|
||||
continue;
|
||||
|
||||
if (rel_path.extension() == ".rpf")
|
||||
traverse_rpf_file(rel_path.u8string());
|
||||
traverse_rpf_file(utf8_rel_path);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::filesystem::path> yim_fipackfile::get_file_paths(std::string parent)
|
||||
std::vector<std::string> yim_fipackfile::get_file_paths(std::string parent)
|
||||
{
|
||||
std::vector<std::filesystem::path> file_paths;
|
||||
std::vector<std::string> file_paths;
|
||||
if (parent.empty())
|
||||
parent = mount_name;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include <pugixml.hpp>
|
||||
#include <gta/fidevice.hpp>
|
||||
#include <pugixml.hpp>
|
||||
|
||||
namespace big
|
||||
{
|
||||
@ -19,10 +19,10 @@ namespace big
|
||||
|
||||
static void add_wrapper_call_back(std::function<void(yim_fipackfile& rpf_wrapper, std::filesystem::path path)> cb);
|
||||
|
||||
static void traverse_rpf_file(const std::u8string& path, int depth = 0);
|
||||
static void traverse_rpf_file(const std::string& path, int depth = 0);
|
||||
static void for_each_fipackfile();
|
||||
|
||||
std::vector<std::filesystem::path> get_file_paths(std::string parent = {});
|
||||
std::vector<std::string> get_file_paths(std::string parent = {});
|
||||
|
||||
const char* get_name();
|
||||
|
||||
|
Reference in New Issue
Block a user