Fix GTA data caching less weapons/vehicles on init (#1264)
This commit is contained in:
parent
a9f934b026
commit
7537b9b343
@ -8,8 +8,12 @@ namespace big
|
|||||||
bool hooks::fipackfile_mount(rage::fiPackfile* this_, const char* mount_point)
|
bool hooks::fipackfile_mount(rage::fiPackfile* this_, const char* mount_point)
|
||||||
{
|
{
|
||||||
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);
|
||||||
|
@ -18,28 +18,18 @@ namespace big
|
|||||||
|
|
||||||
void yim_fipackfile::for_each_fipackfile()
|
void yim_fipackfile::for_each_fipackfile()
|
||||||
{
|
{
|
||||||
// for not hanging the game too much
|
for (int i = 0; i < 3672; i++)
|
||||||
constexpr auto yield_increment = 80;
|
|
||||||
|
|
||||||
auto i = 1;
|
|
||||||
while (g_pointers->m_gta.m_fipackfile_instances[i])
|
|
||||||
{
|
{
|
||||||
auto* rpf = g_pointers->m_gta.m_fipackfile_instances[i];
|
auto* rpf = g_pointers->m_gta.m_fipackfile_instances[i];
|
||||||
|
|
||||||
// its hard coded in the binary?
|
if (rpf)
|
||||||
if (++i >= 3672)
|
|
||||||
{
|
{
|
||||||
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<size_t(yim_fipackfile & rpf_wrapper)> 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<size_t(yim_fipackfile & rpf_wrapper)> cb) {
|
|
||||||
cb(rpf_wrapper);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (i % yield_increment == 0)
|
|
||||||
script::get_current()->yield();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user