fix(cache): less peds on init (#1268)
This commit is contained in:
parent
7537b9b343
commit
99bbe9ae1c
@ -9,24 +9,21 @@ namespace big
|
|||||||
{
|
{
|
||||||
static bool init = ([] {
|
static bool init = ([] {
|
||||||
if (g_gta_data_service->state() == eGtaDataUpdateState::ON_INIT_WAITING)
|
if (g_gta_data_service->state() == eGtaDataUpdateState::ON_INIT_WAITING)
|
||||||
{
|
|
||||||
// parse RPFs loaded before init
|
|
||||||
yim_fipackfile::for_each_fipackfile();
|
|
||||||
g_gta_data_service->set_state(eGtaDataUpdateState::ON_INIT_UPDATE_START);
|
g_gta_data_service->set_state(eGtaDataUpdateState::ON_INIT_UPDATE_START);
|
||||||
}
|
|
||||||
}(),true);
|
}(),true);
|
||||||
|
|
||||||
auto result = g_hooking->get_original<fipackfile_mount>()(this_, mount_point);
|
auto result = g_hooking->get_original<fipackfile_mount>()(this_, mount_point);
|
||||||
|
|
||||||
if (g_gta_data_service->state() == eGtaDataUpdateState::ON_INIT_UPDATE_START)
|
if (g_gta_data_service->state() == eGtaDataUpdateState::ON_INIT_UPDATE_START)
|
||||||
{
|
{
|
||||||
yim_fipackfile rpf_wrapper = yim_fipackfile(this_);
|
yim_fipackfile rpf_wrapper = yim_fipackfile(this_, mount_point);
|
||||||
std::for_each(yim_fipackfile::m_wrapper_call_back.begin(), yim_fipackfile::m_wrapper_call_back.end(), [&rpf_wrapper](std::function<size_t(yim_fipackfile & rpf_wrapper)> cb) {
|
std::for_each(yim_fipackfile::m_wrapper_call_back.begin(), yim_fipackfile::m_wrapper_call_back.end(), [&rpf_wrapper](std::function<size_t(yim_fipackfile & rpf_wrapper)> cb) {
|
||||||
cb(rpf_wrapper);
|
cb(rpf_wrapper);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!stricmp(this_->GetName(), "BgScript.rpf"))
|
if (!stricmp(this_->GetName(), "BgScript.rpf"))
|
||||||
{
|
{
|
||||||
|
yim_fipackfile::for_each_fipackfile();
|
||||||
g_gta_data_service->set_state(eGtaDataUpdateState::ON_INIT_UPDATE_END);
|
g_gta_data_service->set_state(eGtaDataUpdateState::ON_INIT_UPDATE_END);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,9 +30,9 @@ namespace big
|
|||||||
}
|
}
|
||||||
|
|
||||||
gta_data_service::gta_data_service() :
|
gta_data_service::gta_data_service() :
|
||||||
m_peds_cache(g_file_manager->get_project_file("./cache/peds.bin"), 3),
|
m_peds_cache(g_file_manager->get_project_file("./cache/peds.bin"), 4),
|
||||||
m_vehicles_cache(g_file_manager->get_project_file("./cache/vehicles.bin"), 2),
|
m_vehicles_cache(g_file_manager->get_project_file("./cache/vehicles.bin"), 3),
|
||||||
m_weapons_cache(g_file_manager->get_project_file("./cache/weapons.bin"), 3),
|
m_weapons_cache(g_file_manager->get_project_file("./cache/weapons.bin"), 4),
|
||||||
m_update_state(eGtaDataUpdateState::IDLE)
|
m_update_state(eGtaDataUpdateState::IDLE)
|
||||||
{
|
{
|
||||||
if (!is_cache_up_to_date())
|
if (!is_cache_up_to_date())
|
||||||
|
@ -6,9 +6,10 @@
|
|||||||
|
|
||||||
namespace big
|
namespace big
|
||||||
{
|
{
|
||||||
yim_fipackfile::yim_fipackfile(rage::fiPackfile* rpf)
|
yim_fipackfile::yim_fipackfile(rage::fiPackfile* rpf, const std::string& mount_name)
|
||||||
{
|
{
|
||||||
this->rpf = rpf;
|
this->rpf = rpf;
|
||||||
|
this->mount_name = mount_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void yim_fipackfile::add_wrapper_call_back(std::function<size_t(yim_fipackfile& rpf_wrapper)> cb)
|
void yim_fipackfile::add_wrapper_call_back(std::function<size_t(yim_fipackfile& rpf_wrapper)> cb)
|
||||||
@ -18,7 +19,7 @@ namespace big
|
|||||||
|
|
||||||
void yim_fipackfile::for_each_fipackfile()
|
void yim_fipackfile::for_each_fipackfile()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 3672; i++)
|
for (int i = 1; i < 3672; i++) // fipackfile ctor start with 1
|
||||||
{
|
{
|
||||||
auto* rpf = g_pointers->m_gta.m_fipackfile_instances[i];
|
auto* rpf = g_pointers->m_gta.m_fipackfile_instances[i];
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ namespace big
|
|||||||
{
|
{
|
||||||
std::vector<std::filesystem::path> file_paths;
|
std::vector<std::filesystem::path> file_paths;
|
||||||
if (parent.empty())
|
if (parent.empty())
|
||||||
parent = "/";
|
parent = mount_name;
|
||||||
|
|
||||||
std::vector<std::string> directories;
|
std::vector<std::string> directories;
|
||||||
|
|
||||||
|
@ -8,11 +8,10 @@ namespace big
|
|||||||
class yim_fipackfile
|
class yim_fipackfile
|
||||||
{
|
{
|
||||||
rage::fiPackfile* rpf;
|
rage::fiPackfile* rpf;
|
||||||
|
std::string mount_name;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit yim_fipackfile(rage::fiPackfile* rpf);
|
explicit yim_fipackfile(rage::fiPackfile* rpf, const std::string& mount_name = "/");
|
||||||
|
|
||||||
static std::vector<std::string> get_non_dlc_mounted_devices_names();
|
|
||||||
|
|
||||||
static inline std::vector<std::function<size_t(yim_fipackfile& rpf_wrapper)>> m_wrapper_call_back;
|
static inline std::vector<std::function<size_t(yim_fipackfile& rpf_wrapper)>> m_wrapper_call_back;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user