Added g_local_player pointer sanity checks. (#2792)

This commit is contained in:
gir489 2024-03-01 11:48:20 -05:00 committed by GitHub
parent 903c5273ed
commit f4e0da5ff4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 16 additions and 7 deletions

View File

@ -7,6 +7,9 @@ namespace big
{
void looped::vehicle_boost_behavior()
{
if (g_local_player == nullptr)
return;
auto* const vehicle = g_local_player->m_vehicle;
bool is_rocket = VEHICLE::GET_HAS_ROCKET_BOOST(self::veh);

View File

@ -15,7 +15,7 @@ namespace big
virtual void on_tick() override
{
if (!self::veh || !g_local_player->m_vehicle || HUD::IS_PAUSE_MENU_ACTIVE() || HUD::IS_WARNING_MESSAGE_ACTIVE() || CAM::IS_SCREEN_FADED_OUT() || CAM::IS_SCREEN_FADING_OUT() || CAM::IS_SCREEN_FADING_IN())
if (!self::veh || !g_local_player || !g_local_player->m_vehicle || HUD::IS_PAUSE_MENU_ACTIVE() || HUD::IS_WARNING_MESSAGE_ACTIVE() || CAM::IS_SCREEN_FADED_OUT() || CAM::IS_SCREEN_FADING_OUT() || CAM::IS_SCREEN_FADING_IN())
{
return;
}

View File

@ -108,11 +108,14 @@ namespace big
virtual void on_enable() override
{
reset(g_local_player->m_vehicle);
if (g_local_player)
reset(g_local_player->m_vehicle);
}
virtual void on_tick() override
{
if (g_local_player == nullptr)
return;
const auto curr_veh = g_local_player->m_vehicle;
if (curr_veh && !(g_local_player->m_ped_task_flag & (int)ePedTask::TASK_DRIVING))
{

View File

@ -155,7 +155,7 @@ namespace big
{
for (int i = 0; i < 16; i++)
{
if (node->m_has_occupants[i] && node->m_occupants[i] == g_local_player->m_net_object->m_object_id)
if (g_local_player && node->m_has_occupants[i] && node->m_occupants[i] == g_local_player->m_net_object->m_object_id)
return true;
}

View File

@ -18,11 +18,14 @@ namespace big
ImGui::SliderFloat("VIEW_BLACKHOLE_SCALE"_T.data(), &g.world.blackhole.scale, 2.f, 12.f, "%.0f");
components::button("VIEW_BLACKHOLE_SET"_T, [] {
const auto player_pos = g_local_player->get_position();
if (g_local_player)
{
const auto player_pos = g_local_player->get_position();
g.world.blackhole.pos.x = player_pos->x;
g.world.blackhole.pos.y = player_pos->y;
g.world.blackhole.pos.z = player_pos->z;
g.world.blackhole.pos.x = player_pos->x;
g.world.blackhole.pos.y = player_pos->y;
g.world.blackhole.pos.z = player_pos->z;
}
});
ImGui::SeparatorText("VIEW_BLACKHOLE_CUSTOM"_T.data());