fix(Mobile): Crash while in loading (before globals are available)

This commit is contained in:
Yimura 2022-05-10 20:38:24 +02:00
parent 7ddca9d877
commit 5024ea4d9d
No known key found for this signature in database
GPG Key ID: 3D8FF4397E768682

View File

@ -38,25 +38,32 @@ namespace big
g_mobile_service->refresh_personal_vehicles(); g_mobile_service->refresh_personal_vehicles();
if (ImGui::ListBoxHeader("##personal_veh_list", { 400.f, 500.f })) if (ImGui::ListBoxHeader("##personal_veh_list", { 400.f, 500.f }))
{ {
const auto personal_veh_idx = mobile::util::get_current_personal_vehicle(); if (g_mobile_service->personal_vehicles().empty())
for (const auto& it : g_mobile_service->personal_vehicles())
{ {
const auto& label = it.first; ImGui::Text("No personal vehicle found, are you online?");
const auto& personal_veh = it.second; }
else
auto lower = label; {
std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower); const auto personal_veh_idx = mobile::util::get_current_personal_vehicle();
for (const auto& it : g_mobile_service->personal_vehicles())
if (lower.find(lower_search) != std::string::npos)
{ {
if (ImGui::Selectable(label.c_str(), personal_veh->get_id() == personal_veh_idx)) const auto& label = it.first;
{ const auto& personal_veh = it.second;
strcpy(search, "");
lower_search = search;
g_fiber_pool->queue_job([&personal_veh] { auto lower = label;
personal_veh->summon(); std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
});
if (lower.find(lower_search) != std::string::npos)
{
if (ImGui::Selectable(label.c_str(), personal_veh->get_id() == personal_veh_idx))
{
strcpy(search, "");
lower_search = search;
g_fiber_pool->queue_job([&personal_veh] {
personal_veh->summon();
});
}
} }
} }
} }