From 5024ea4d9d038873861de969a09d9a29f0619b1f Mon Sep 17 00:00:00 2001 From: Yimura Date: Tue, 10 May 2022 20:38:24 +0200 Subject: [PATCH] fix(Mobile): Crash while in loading (before globals are available) --- BigBaseV2/src/views/self/view_mobile.cpp | 39 ++++++++++++++---------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/BigBaseV2/src/views/self/view_mobile.cpp b/BigBaseV2/src/views/self/view_mobile.cpp index f60b5513..880ae346 100644 --- a/BigBaseV2/src/views/self/view_mobile.cpp +++ b/BigBaseV2/src/views/self/view_mobile.cpp @@ -38,25 +38,32 @@ namespace big g_mobile_service->refresh_personal_vehicles(); if (ImGui::ListBoxHeader("##personal_veh_list", { 400.f, 500.f })) { - const auto personal_veh_idx = mobile::util::get_current_personal_vehicle(); - for (const auto& it : g_mobile_service->personal_vehicles()) + if (g_mobile_service->personal_vehicles().empty()) { - const auto& label = it.first; - const auto& personal_veh = it.second; - - auto lower = label; - std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower); - - if (lower.find(lower_search) != std::string::npos) + ImGui::Text("No personal vehicle found, are you online?"); + } + else + { + const auto personal_veh_idx = mobile::util::get_current_personal_vehicle(); + for (const auto& it : g_mobile_service->personal_vehicles()) { - if (ImGui::Selectable(label.c_str(), personal_veh->get_id() == personal_veh_idx)) - { - strcpy(search, ""); - lower_search = search; + const auto& label = it.first; + const auto& personal_veh = it.second; - g_fiber_pool->queue_job([&personal_veh] { - personal_veh->summon(); - }); + auto lower = label; + 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(); + }); + } } } }