Fix GTA data caching less weapons/vehicles on init (#1264)

This commit is contained in:
maybegreat48
2023-04-18 20:21:45 +00:00
committed by GitHub
parent a5627476f7
commit 1241f9835f
2 changed files with 12 additions and 18 deletions

View File

@ -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<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();
}
}