Sanity checks for get_net_data. (#3068)

This commit is contained in:
gir489 2024-05-08 04:33:21 -04:00 committed by GitHub
parent 543c229be2
commit ce62f3d04b

View File

@ -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