Fixed Player ESP potentially crashing on invalid models. (#2431)

* Check for and handle non-normal player models when doing ESP to prevent crashes.

* Added sanity checks to the non-MP model scenario.
This commit is contained in:
gir489 2023-11-19 16:45:43 -05:00 committed by GitHub
parent 99af31cfa0
commit 0b0bde5958
4 changed files with 19 additions and 5 deletions

View File

@ -198,5 +198,5 @@ namespace big::functions
using remove_player_from_sender_list = bool(*)(void* list, uint64_t* rockstar_id); using remove_player_from_sender_list = bool(*)(void* list, uint64_t* rockstar_id);
using get_ped_pone = bool(*)(CPed* ped_ptr, rage::fvector4& output, PedBones bone); using get_ped_bone = bool(*)(CPed* ped_ptr, rage::fvector4& output, PedBones bone);
} }

View File

@ -359,7 +359,7 @@ namespace big
PVOID m_game_skeleton_update; PVOID m_game_skeleton_update;
functions::get_ped_pone m_get_ped_pone; functions::get_ped_bone m_get_ped_bone;
}; };
#pragma pack(pop) #pragma pack(pop)
static_assert(sizeof(gta_pointers) % 8 == 0, "Pointers are not properly aligned"); static_assert(sizeof(gta_pointers) % 8 == 0, "Pointers are not properly aligned");

View File

@ -1764,7 +1764,7 @@ namespace big
"48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 48 83 EC 60 48 8B 01 41 8B E8 48 8B F2", "48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 48 83 EC 60 48 8B 01 41 8B E8 48 8B F2",
[](memory::handle ptr) [](memory::handle ptr)
{ {
g_pointers->m_gta.m_get_ped_pone = ptr.as<functions::get_ped_pone>(); g_pointers->m_gta.m_get_ped_bone = ptr.as<functions::get_ped_bone>();
} }
} }
>(); // don't leave a trailing comma at the end >(); // don't leave a trailing comma at the end

View File

@ -25,8 +25,22 @@ namespace big
return; return;
rage::fvector4 player_pos; rage::fvector4 player_pos;
if (!g_pointers->m_gta.m_get_ped_pone(plyr->get_ped(), player_pos, PedBones::SKEL_Pelvis))
if (plyr->get_ped()->m_model_info->m_hash == RAGE_JOAAT("mp_m_freemode_01") || plyr->get_ped()->m_model_info->m_hash == RAGE_JOAAT("mp_f_freemode_01"))
{
if (!g_pointers->m_gta.m_get_ped_bone(plyr->get_ped(), player_pos, PedBones::SKEL_Pelvis))
return; return;
}
else
{
if (plyr->get_ped()->GetNavigation() == nullptr)
return;
if (auto navigation_pos = plyr->get_ped()->GetNavigation()->get_position())
player_pos = {navigation_pos->x, navigation_pos->y, navigation_pos->z, 0};
else
return;
}
float screen_x, screen_y; float screen_x, screen_y;