Prevent repeat calls to cache rebuild causing a crash. (#3662)
This commit is contained in:
parent
21d8a81756
commit
41942f4d84
@ -271,19 +271,26 @@ namespace big
|
|||||||
|
|
||||||
void gta_data_service::rebuild_cache()
|
void gta_data_service::rebuild_cache()
|
||||||
{
|
{
|
||||||
|
static bool completed = false;
|
||||||
|
|
||||||
|
if (completed == true)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
using hash_array = std::vector<uint32_t>;
|
using hash_array = std::vector<uint32_t>;
|
||||||
hash_array mapped_peds;
|
hash_array mapped_peds{};
|
||||||
hash_array mapped_vehicles;
|
hash_array mapped_vehicles{};
|
||||||
hash_array mapped_weapons;
|
hash_array mapped_weapons{};
|
||||||
hash_array mapped_components;
|
hash_array mapped_components{};
|
||||||
|
|
||||||
int mp_weapons_thread_id = 0;
|
int mp_weapons_thread_id = 0;
|
||||||
|
|
||||||
std::vector<ped_item> peds;
|
std::vector<ped_item> peds{};
|
||||||
std::vector<vehicle_item> vehicles;
|
std::vector<vehicle_item> vehicles{};
|
||||||
//std::vector<weapon_item> weapons;
|
//std::vector<weapon_item> weapons;
|
||||||
std::unordered_map<Hash, weapon_item_parsed> weapons;
|
std::unordered_map<Hash, weapon_item_parsed> weapons{};
|
||||||
std::vector<weapon_component> weapon_components;
|
std::vector<weapon_component> weapon_components{};
|
||||||
|
|
||||||
constexpr auto exists = [](const hash_array& arr, uint32_t val) -> bool {
|
constexpr auto exists = [](const hash_array& arr, uint32_t val) -> bool {
|
||||||
return std::find(arr.begin(), arr.end(), val) != arr.end();
|
return std::find(arr.begin(), arr.end(), val) != arr.end();
|
||||||
@ -675,6 +682,8 @@ namespace big
|
|||||||
LOG(INFO) << "Finished writing cache to disk.";
|
LOG(INFO) << "Finished writing cache to disk.";
|
||||||
|
|
||||||
load_data();
|
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)
|
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());
|
.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.set_state(eGtaDataUpdateState::NEEDS_UPDATE);
|
||||||
g_gta_data_service.update_now();
|
g_gta_data_service.update_now();
|
||||||
|
Reference in New Issue
Block a user