diff --git a/src/hooks/protections/receive_net_message.cpp b/src/hooks/protections/receive_net_message.cpp index ee385ba9..2efcba0c 100644 --- a/src/hooks/protections/receive_net_message.cpp +++ b/src/hooks/protections/receive_net_message.cpp @@ -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; + } } } diff --git a/src/hooks/protections/received_clone_remove.cpp b/src/hooks/protections/received_clone_remove.cpp index e865a6e1..0df2bec9 100644 --- a/src/hooks/protections/received_clone_remove.cpp +++ b/src/hooks/protections/received_clone_remove.cpp @@ -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; diff --git a/src/services/players/player_service.cpp b/src/services/players/player_service.cpp index c58b0b28..7318a68f 100644 --- a/src/services/players/player_service.cpp +++ b/src/services/players/player_service.cpp @@ -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; }