mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2024-12-22 20:17:24 +08:00
Fix multiple crashes. (#3035)
This commit is contained in:
parent
03fb470983
commit
93c95c51c3
@ -83,15 +83,18 @@ namespace big
|
||||
buffer.m_flagBits = 1;
|
||||
|
||||
rage::eNetMessage msgType;
|
||||
player_ptr player;
|
||||
player_ptr player = nullptr;
|
||||
|
||||
for (uint32_t i = 0; i < gta_util::get_network()->m_game_session_ptr->m_player_count; i++)
|
||||
{
|
||||
if (gta_util::get_network()->m_game_session_ptr->m_players[i]->m_player_data.m_peer_id_2 == frame->m_peer_id)
|
||||
if (auto player_iter = gta_util::get_network()->m_game_session_ptr->m_players[i])
|
||||
{
|
||||
player = g_player_service->get_by_host_token(
|
||||
gta_util::get_network()->m_game_session_ptr->m_players[i]->m_player_data.m_host_token);
|
||||
break;
|
||||
if (frame && player_iter->m_player_data.m_peer_id_2 == frame->m_peer_id)
|
||||
{
|
||||
player = g_player_service->get_by_host_token(
|
||||
gta_util::get_network()->m_game_session_ptr->m_players[i]->m_player_data.m_host_token);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,8 @@ namespace big
|
||||
{
|
||||
void hooks::received_clone_remove(CNetworkObjectMgr* mgr, CNetGamePlayer* src, CNetGamePlayer* dst, int16_t object_id, uint32_t ownership_token)
|
||||
{
|
||||
if (dst->m_player_info->m_ped->m_net_object->m_object_id == object_id) [[unlikely]]
|
||||
if (!dst || !dst->m_player_info || !dst->m_player_info->m_ped || !dst->m_player_info->m_ped->m_net_object
|
||||
|| dst->m_player_info->m_ped->m_net_object->m_object_id == object_id) [[unlikely]]
|
||||
{
|
||||
notify::crash_blocked(src, "player ped removal");
|
||||
return;
|
||||
|
@ -38,24 +38,42 @@ namespace big
|
||||
player_ptr player_service::get_by_msg_id(uint32_t msg_id) const
|
||||
{
|
||||
for (const auto& [_, player] : m_players)
|
||||
if (player->get_net_game_player()->m_msg_id == msg_id)
|
||||
return player;
|
||||
{
|
||||
if (auto net_game_player = player->get_net_game_player())
|
||||
{
|
||||
if (net_game_player->m_msg_id == msg_id)
|
||||
{
|
||||
return player;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
player_ptr player_service::get_by_id(uint32_t id) const
|
||||
{
|
||||
for (const auto& [_, player] : m_players)
|
||||
if (player->id() == id)
|
||||
{
|
||||
if (player && player->id() == id)
|
||||
{
|
||||
return player;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
player_ptr player_service::get_by_host_token(uint64_t token) const
|
||||
{
|
||||
for (const auto& [_, player] : m_players)
|
||||
if (player->get_net_data()->m_host_token == token)
|
||||
return player;
|
||||
{
|
||||
if (auto net_data = player->get_net_data())
|
||||
{
|
||||
if (net_data->m_host_token == token)
|
||||
{
|
||||
return player;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user