diff --git a/src/hooks/misc/fipackfile_mount.cpp b/src/hooks/misc/fipackfile_mount.cpp index 240a2653..773bbafd 100644 --- a/src/hooks/misc/fipackfile_mount.cpp +++ b/src/hooks/misc/fipackfile_mount.cpp @@ -8,8 +8,12 @@ namespace big bool hooks::fipackfile_mount(rage::fiPackfile* this_, const char* mount_point) { 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); + } }(),true); auto result = g_hooking->get_original()(this_, mount_point); diff --git a/src/services/gta_data/yim_fipackfile.cpp b/src/services/gta_data/yim_fipackfile.cpp index 533a547f..7b763699 100644 --- a/src/services/gta_data/yim_fipackfile.cpp +++ b/src/services/gta_data/yim_fipackfile.cpp @@ -18,28 +18,18 @@ namespace big void yim_fipackfile::for_each_fipackfile() { - // for not hanging the game too much - constexpr auto yield_increment = 80; - - auto i = 1; - while (g_pointers->m_gta.m_fipackfile_instances[i]) + for (int i = 0; i < 3672; i++) { auto* rpf = g_pointers->m_gta.m_fipackfile_instances[i]; - // its hard coded in the binary? - if (++i >= 3672) + if (rpf) { - break; + yim_fipackfile rpf_wrapper = yim_fipackfile(rpf); + + 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); + }); } - - yim_fipackfile rpf_wrapper = yim_fipackfile(rpf); - - std::for_each(m_wrapper_call_back.begin(), m_wrapper_call_back.end(), [&rpf_wrapper](std::function cb) { - cb(rpf_wrapper); - }); - - if (i % yield_increment == 0) - script::get_current()->yield(); } }