mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2024-12-22 12:07:46 +08:00
Prevent repeat calls to cache rebuild causing a crash. (#3662)
This commit is contained in:
parent
a62ea11553
commit
0d18cd6e59
@ -271,19 +271,26 @@ namespace big
|
||||
|
||||
void gta_data_service::rebuild_cache()
|
||||
{
|
||||
static bool completed = false;
|
||||
|
||||
if (completed == true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using hash_array = std::vector<uint32_t>;
|
||||
hash_array mapped_peds;
|
||||
hash_array mapped_vehicles;
|
||||
hash_array mapped_weapons;
|
||||
hash_array mapped_components;
|
||||
hash_array mapped_peds{};
|
||||
hash_array mapped_vehicles{};
|
||||
hash_array mapped_weapons{};
|
||||
hash_array mapped_components{};
|
||||
|
||||
int mp_weapons_thread_id = 0;
|
||||
|
||||
std::vector<ped_item> peds;
|
||||
std::vector<vehicle_item> vehicles;
|
||||
std::vector<ped_item> peds{};
|
||||
std::vector<vehicle_item> vehicles{};
|
||||
//std::vector<weapon_item> weapons;
|
||||
std::unordered_map<Hash, weapon_item_parsed> weapons;
|
||||
std::vector<weapon_component> weapon_components;
|
||||
std::unordered_map<Hash, weapon_item_parsed> weapons{};
|
||||
std::vector<weapon_component> weapon_components{};
|
||||
|
||||
constexpr auto exists = [](const hash_array& arr, uint32_t val) -> bool {
|
||||
return std::find(arr.begin(), arr.end(), val) != arr.end();
|
||||
@ -675,6 +682,8 @@ namespace big
|
||||
LOG(INFO) << "Finished writing cache to disk.";
|
||||
|
||||
load_data();
|
||||
|
||||
completed = true; //Prevent repeat calls.
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ namespace big
|
||||
ImGui::Text(std::format("{}: {}\n{}: {}\n{}: {}\n{}: {}", "VIEW_GTA_CACHE_PEDS_CACHED"_T, ped_count, "VIEW_GTA_CACHE_VEHICLES_CACHED"_T, veh_count, "VIEW_GTA_CACHE_WEAPONS_CACHED"_T, wep_count, "VIEW_GTA_CACHE_WEAPON_COMPONENTS_CACHED"_T, wep_comp_count)
|
||||
.c_str());
|
||||
|
||||
if (components::button("VIEW_GTA_CACHE_REBUILD_CACHE"_T))
|
||||
if (!*g_pointers->m_gta.m_is_session_started && components::button("VIEW_GTA_CACHE_REBUILD_CACHE"_T))
|
||||
{
|
||||
g_gta_data_service.set_state(eGtaDataUpdateState::NEEDS_UPDATE);
|
||||
g_gta_data_service.update_now();
|
||||
|
Loading…
Reference in New Issue
Block a user