From ce62f3d04b982ad048e759453f47ad02e5720670 Mon Sep 17 00:00:00 2001 From: gir489 <100792176+gir489returns@users.noreply.github.com> Date: Wed, 8 May 2024 04:33:21 -0400 Subject: [PATCH] Sanity checks for get_net_data. (#3068) --- src/services/players/player.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/services/players/player.cpp b/src/services/players/player.cpp index 5116767d..6a055b4f 100644 --- a/src/services/players/player.cpp +++ b/src/services/players/player.cpp @@ -25,17 +25,17 @@ namespace big const char* player::get_name() const { - return m_net_game_player == nullptr ? "" : m_net_game_player->get_name(); + return get_net_game_player() == nullptr ? "" : m_net_game_player->get_name(); } rage::rlGamerInfo* player::get_net_data() const { - return m_net_game_player == nullptr ? nullptr : m_net_game_player->get_net_data(); + return get_net_game_player() == nullptr ? nullptr : m_net_game_player->get_net_data(); } CNetGamePlayer* player::get_net_game_player() const { - return m_net_game_player; + return (m_net_game_player == nullptr || m_net_game_player->m_player_info == nullptr) ? nullptr : m_net_game_player; } CPed* player::get_ped() const @@ -48,8 +48,8 @@ namespace big CPlayerInfo* player::get_player_info() const { - if (m_net_game_player != nullptr && m_net_game_player->m_player_info != nullptr) - return m_net_game_player->m_player_info; + if (auto net_player = get_net_game_player()) + return net_player->m_player_info; return nullptr; } @@ -128,14 +128,14 @@ namespace big uint8_t player::id() const { if (*g_pointers->m_gta.m_is_session_started) - return m_net_game_player == nullptr ? -1 : m_net_game_player->m_player_id; + return get_net_game_player() == nullptr ? -1 : m_net_game_player->m_player_id; else return self::id; } bool player::is_host() const { - return m_net_game_player == nullptr ? false : m_net_game_player->is_host(); + return get_net_game_player() == nullptr ? false : m_net_game_player->is_host(); } bool player::is_friend() const @@ -145,12 +145,12 @@ namespace big bool player::is_valid() const { - return m_net_game_player == nullptr ? false : m_net_game_player->is_valid(); + return get_net_game_player() == nullptr ? false : m_net_game_player->is_valid(); } bool player::equals(const CNetGamePlayer* net_game_player) const { - return net_game_player == m_net_game_player; + return net_game_player == get_net_game_player(); } std::string player::to_lowercase_identifier() const