From 99bbe9ae1c0b3df1f8582a8a71e8581add6e7416 Mon Sep 17 00:00:00 2001 From: Aure7138 <100095051+Aure7138@users.noreply.github.com> Date: Wed, 19 Apr 2023 16:57:49 +0800 Subject: [PATCH] fix(cache): less peds on init (#1268) --- src/hooks/misc/fipackfile_mount.cpp | 7 ++----- src/services/gta_data/gta_data_service.cpp | 6 +++--- src/services/gta_data/yim_fipackfile.cpp | 7 ++++--- src/services/gta_data/yim_fipackfile.hpp | 5 ++--- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/hooks/misc/fipackfile_mount.cpp b/src/hooks/misc/fipackfile_mount.cpp index 773bbafd..230235d7 100644 --- a/src/hooks/misc/fipackfile_mount.cpp +++ b/src/hooks/misc/fipackfile_mount.cpp @@ -9,24 +9,21 @@ namespace big { static bool init = ([] { 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); - } }(),true); auto result = g_hooking->get_original()(this_, mount_point); 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 cb) { cb(rpf_wrapper); }); if (!stricmp(this_->GetName(), "BgScript.rpf")) { + yim_fipackfile::for_each_fipackfile(); g_gta_data_service->set_state(eGtaDataUpdateState::ON_INIT_UPDATE_END); } } diff --git a/src/services/gta_data/gta_data_service.cpp b/src/services/gta_data/gta_data_service.cpp index e3c39898..9d453805 100644 --- a/src/services/gta_data/gta_data_service.cpp +++ b/src/services/gta_data/gta_data_service.cpp @@ -30,9 +30,9 @@ namespace big } gta_data_service::gta_data_service() : - m_peds_cache(g_file_manager->get_project_file("./cache/peds.bin"), 3), - m_vehicles_cache(g_file_manager->get_project_file("./cache/vehicles.bin"), 2), - m_weapons_cache(g_file_manager->get_project_file("./cache/weapons.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"), 3), + m_weapons_cache(g_file_manager->get_project_file("./cache/weapons.bin"), 4), m_update_state(eGtaDataUpdateState::IDLE) { if (!is_cache_up_to_date()) diff --git a/src/services/gta_data/yim_fipackfile.cpp b/src/services/gta_data/yim_fipackfile.cpp index 7b763699..60f32595 100644 --- a/src/services/gta_data/yim_fipackfile.cpp +++ b/src/services/gta_data/yim_fipackfile.cpp @@ -6,9 +6,10 @@ 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->mount_name = mount_name; } void yim_fipackfile::add_wrapper_call_back(std::function cb) @@ -18,7 +19,7 @@ namespace big 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]; @@ -37,7 +38,7 @@ namespace big { std::vector file_paths; if (parent.empty()) - parent = "/"; + parent = mount_name; std::vector directories; diff --git a/src/services/gta_data/yim_fipackfile.hpp b/src/services/gta_data/yim_fipackfile.hpp index d7a743df..67eeb7e5 100644 --- a/src/services/gta_data/yim_fipackfile.hpp +++ b/src/services/gta_data/yim_fipackfile.hpp @@ -8,11 +8,10 @@ namespace big class yim_fipackfile { rage::fiPackfile* rpf; + std::string mount_name; public: - explicit yim_fipackfile(rage::fiPackfile* rpf); - - static std::vector get_non_dlc_mounted_devices_names(); + explicit yim_fipackfile(rage::fiPackfile* rpf, const std::string& mount_name = "/"); static inline std::vector> m_wrapper_call_back;