fix(GtaDataService): Rebuild Cache button not working (#3411)
Changes: - Switch from pointer singleton to pre-instanced singleton - Added default constructor to cache_file object - Fixed an issue where maps and vectors would not be cleared before (re)generating a cache.
This commit is contained in:
@ -55,7 +55,7 @@ namespace big
|
||||
|
||||
|
||||
static int selected_class = -1;
|
||||
const auto& class_arr = g_gta_data_service->vehicle_classes();
|
||||
const auto& class_arr = g_gta_data_service.vehicle_classes();
|
||||
|
||||
ImGui::SetNextItemWidth(300.f);
|
||||
if (ImGui::BeginCombo("VEHICLE_CLASS"_T.data(),
|
||||
@ -125,7 +125,7 @@ namespace big
|
||||
{
|
||||
const auto& label = it.first;
|
||||
const auto& personal_veh = it.second;
|
||||
const auto& item = g_gta_data_service->vehicle_by_hash(personal_veh->get_hash());
|
||||
const auto& item = g_gta_data_service.vehicle_by_hash(personal_veh->get_hash());
|
||||
|
||||
std::string vehicle_class = item.m_vehicle_class;
|
||||
std::string display_name = label;
|
||||
|
@ -32,7 +32,7 @@ namespace big
|
||||
});
|
||||
|
||||
static int selected_class = -1;
|
||||
const auto& class_arr = g_gta_data_service->vehicle_classes();
|
||||
const auto& class_arr = g_gta_data_service.vehicle_classes();
|
||||
|
||||
ImGui::SetNextItemWidth(300.f);
|
||||
if (ImGui::BeginCombo("VEHICLE_CLASS"_T.data(),
|
||||
@ -66,9 +66,9 @@ namespace big
|
||||
|
||||
vehicle_map calculated_map{};
|
||||
|
||||
if (g_gta_data_service->vehicles().size() > 0)
|
||||
if (g_gta_data_service.vehicles().size() > 0)
|
||||
{
|
||||
for (auto& item : g_gta_data_service->vehicles())
|
||||
for (auto& item : g_gta_data_service.vehicles())
|
||||
{
|
||||
const auto& vehicle = item.second;
|
||||
|
||||
@ -82,15 +82,16 @@ namespace big
|
||||
std::string lower_search = search;
|
||||
std::transform(lower_search.begin(), lower_search.end(), lower_search.begin(), tolower);
|
||||
|
||||
if ((selected_class == -1 || class_arr[selected_class] == clazz) && (display_name.find(lower_search) != std::string::npos || display_manufacturer.find(lower_search) != std::string::npos))
|
||||
if ((selected_class == -1 || class_arr[selected_class] == clazz)
|
||||
&& (display_name.find(lower_search) != std::string::npos || display_manufacturer.find(lower_search) != std::string::npos))
|
||||
{
|
||||
calculated_map.emplace(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static const auto over_30 = (30 * ImGui::GetTextLineHeightWithSpacing() + 2);
|
||||
auto calculated_size = calculated_map.size();
|
||||
auto calculated_size = calculated_map.size();
|
||||
if (calculated_map.size() == 0)
|
||||
{
|
||||
calculated_size++;
|
||||
@ -112,7 +113,7 @@ namespace big
|
||||
|
||||
if (veh_hash)
|
||||
{
|
||||
const auto& item = g_gta_data_service->vehicle_by_hash(veh_hash);
|
||||
const auto& item = g_gta_data_service.vehicle_by_hash(veh_hash);
|
||||
|
||||
components::selectable(std::vformat("SPAWN_VEHICLE_CURRENT_VEHICLE"_T, std::make_format_args(item.m_display_name)), false, [] {
|
||||
if (self::veh)
|
||||
@ -166,8 +167,7 @@ namespace big
|
||||
const auto& vehicle = item.second;
|
||||
ImGui::PushID(vehicle.m_hash);
|
||||
components::selectable(vehicle.m_display_name, false, [&vehicle] {
|
||||
const auto spawn_location =
|
||||
vehicle::get_spawn_location(g.spawn_vehicle.spawn_inside, vehicle.m_hash);
|
||||
const auto spawn_location = vehicle::get_spawn_location(g.spawn_vehicle.spawn_inside, vehicle.m_hash);
|
||||
const auto spawn_heading = ENTITY::GET_ENTITY_HEADING(self::ped);
|
||||
|
||||
auto veh = vehicle::spawn(vehicle.m_hash, spawn_location, spawn_heading);
|
||||
|
Reference in New Issue
Block a user