mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2024-12-22 20:17:24 +08:00
Fix player list crash (#3080)
* Fixed get_rockstar_id returning an incorrect type. * Added more OOP usage of get_rockstar_id when applicable. Co-authored-by: gir489returns <gir489returns@outlook.com>
This commit is contained in:
parent
cee89f5e8a
commit
b58d1d189d
@ -19,7 +19,7 @@ namespace big
|
||||
|
||||
virtual void execute(player_ptr player, const command_arguments& _args, const std::shared_ptr<command_context> ctx) override
|
||||
{
|
||||
if (!player)
|
||||
if (!player || !player->is_valid())
|
||||
return;
|
||||
if (gta_util::get_network()->m_game_session_ptr->is_host())
|
||||
{
|
||||
|
@ -25,12 +25,11 @@ namespace big
|
||||
|
||||
if (log)
|
||||
{
|
||||
uint64_t rockstar_id = attacker->get_net_data() == nullptr ? 0 : attacker->get_net_data()->m_gamer_handle.m_rockstar_id;
|
||||
LOGF(WARNING,
|
||||
"Received {} from {} ({}), victim is {}",
|
||||
m_event_name,
|
||||
attacker->get_name(),
|
||||
rockstar_id,
|
||||
attacker->get_rockstar_id(),
|
||||
victim->get_name());
|
||||
}
|
||||
|
||||
|
@ -56,8 +56,7 @@ namespace big
|
||||
|
||||
if (log)
|
||||
{
|
||||
uint64_t rockstar_id = player->get_net_data() == nullptr ? 0 : player->get_net_data()->m_gamer_handle.m_rockstar_id;
|
||||
LOGF(WARNING, "Received {} from {} ({})", m_event_name, player->get_name(), rockstar_id);
|
||||
LOGF(WARNING, "Received {} from {} ({})", m_event_name, player->get_name(), player->get_rockstar_id());
|
||||
}
|
||||
|
||||
if (announce_in_chat)
|
||||
@ -89,8 +88,7 @@ namespace big
|
||||
|
||||
if (log)
|
||||
{
|
||||
uint64_t rockstar_id = player->get_net_data() == nullptr ? 0 : player->get_net_data()->m_gamer_handle.m_rockstar_id;
|
||||
LOGF(WARNING, "Received {} from {} ({})", m_event_name, player->get_name(), rockstar_id);
|
||||
LOGF(WARNING, "Received {} from {} ({})", m_event_name, player->get_name(), player->get_rockstar_id());
|
||||
}
|
||||
|
||||
if (notify)
|
||||
|
@ -35,17 +35,15 @@ namespace big
|
||||
{
|
||||
g_lua_manager->trigger_event<menu_event::PlayerLeave>(net_player_data->m_name);
|
||||
|
||||
auto rockstar_id = net_player_data->m_gamer_handle.m_rockstar_id;
|
||||
|
||||
if (g.notifications.player_leave.log)
|
||||
LOG(INFO) << "Player left '" << net_player_data->m_name << "' freeing slot #" << (int)player->m_player_id
|
||||
<< " with Rockstar ID: " << net_player_data->m_gamer_handle.m_rockstar_id;
|
||||
LOG(INFO) << "Player left '" << net_player_data->m_name << "' freeing slot #" << (int)player->m_player_id << " with Rockstar ID: " << rockstar_id;
|
||||
|
||||
if (g.notifications.player_leave.notify)
|
||||
{
|
||||
g_notification_service.push("PLAYER_LEFT"_T.data(),
|
||||
std::vformat("PLAYER_LEFT_INFO"_T,
|
||||
std::make_format_args(net_player_data->m_name,
|
||||
player->m_player_id,
|
||||
net_player_data->m_gamer_handle.m_rockstar_id)));
|
||||
std::vformat("PLAYER_LEFT_INFO"_T, std::make_format_args(net_player_data->m_name, player->m_player_id, rockstar_id)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,10 +92,9 @@ namespace big
|
||||
g_fiber_pool->queue_job([id] {
|
||||
if (auto plyr = g_player_service->get_by_id(id))
|
||||
{
|
||||
if (plyr->get_net_data()->m_gamer_handle.m_rockstar_id != 0)
|
||||
if (auto rockstar_id = plyr->get_rockstar_id(); rockstar_id != 0)
|
||||
{
|
||||
if (auto entry = g_player_database_service->get_player_by_rockstar_id(
|
||||
plyr->get_net_data()->m_gamer_handle.m_rockstar_id))
|
||||
if (auto entry = g_player_database_service->get_player_by_rockstar_id(rockstar_id))
|
||||
{
|
||||
plyr->is_trusted = entry->is_trusted;
|
||||
if (!(plyr->is_friend() && g.session.trust_friends))
|
||||
|
@ -460,7 +460,7 @@ namespace big
|
||||
&& (!g.debug.logs.script_event.filter_player || g.debug.logs.script_event.player_id == player->m_player_id)) [[unlikely]]
|
||||
{
|
||||
std::stringstream output;
|
||||
output << "Script Event From: " << player->get_name() << " (" << player->get_net_data()->m_gamer_handle.m_rockstar_id << ") Args: { ";
|
||||
output << "Script Event From: " << player->get_name() << " (" << plyr->get_rockstar_id() << ") Args: { ";
|
||||
for (int i = 0; i < args_count; i++)
|
||||
{
|
||||
if (i)
|
||||
|
@ -22,10 +22,13 @@ namespace big
|
||||
if (net_player == nullptr)
|
||||
return false;
|
||||
|
||||
const auto rockstar_id = net_player->get_net_data()->m_gamer_handle.m_rockstar_id;
|
||||
for (uint32_t i = 0; i < g_pointers->m_gta.m_friend_registry->m_friend_count; i++)
|
||||
if (rockstar_id == g_pointers->m_gta.m_friend_registry->get(i)->m_rockstar_id)
|
||||
return true;
|
||||
if (auto net_data = net_player->get_net_data())
|
||||
{
|
||||
const auto rockstar_id = net_data->m_gamer_handle.m_rockstar_id;
|
||||
for (uint32_t i = 0; i < g_pointers->m_gta.m_friend_registry->m_friend_count; i++)
|
||||
if (rockstar_id == g_pointers->m_gta.m_friend_registry->get(i)->m_rockstar_id)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -255,11 +255,11 @@ namespace big
|
||||
|
||||
std::shared_ptr<persistent_player> player_database_service::get_or_create_player(player_ptr player)
|
||||
{
|
||||
if (m_players.contains(player->get_net_data()->m_gamer_handle.m_rockstar_id))
|
||||
return m_players[player->get_net_data()->m_gamer_handle.m_rockstar_id];
|
||||
if (m_players.contains(player->get_rockstar_id()))
|
||||
return m_players[player->get_rockstar_id()];
|
||||
else
|
||||
{
|
||||
auto player_ptr = add_player(player->get_net_data()->m_gamer_handle.m_rockstar_id, player->get_name());
|
||||
auto player_ptr = add_player(player->get_rockstar_id(), player->get_name());
|
||||
save();
|
||||
return player_ptr;
|
||||
}
|
||||
|
@ -38,6 +38,13 @@ namespace big
|
||||
return (m_net_game_player == nullptr || m_net_game_player->m_player_info == nullptr) ? nullptr : m_net_game_player;
|
||||
}
|
||||
|
||||
int64_t player::get_rockstar_id() const
|
||||
{
|
||||
if (auto net_data = get_net_data())
|
||||
return net_data->m_gamer_handle.m_rockstar_id;
|
||||
return 0;
|
||||
}
|
||||
|
||||
CPed* player::get_ped() const
|
||||
{
|
||||
if (const auto player_info = this->get_player_info(); player_info != nullptr)
|
||||
@ -73,8 +80,7 @@ namespace big
|
||||
{
|
||||
for (uint32_t i = 0; i < gta_util::get_network()->m_game_session_ptr->m_peer_count; i++)
|
||||
{
|
||||
if (gta_util::get_network()->m_game_session_ptr->m_peers[i]->m_peer_data.m_gamer_handle.m_rockstar_id
|
||||
== get_net_data()->m_gamer_handle.m_rockstar_id)
|
||||
if (gta_util::get_network()->m_game_session_ptr->m_peers[i]->m_peer_data.m_gamer_handle.m_rockstar_id == get_rockstar_id())
|
||||
{
|
||||
return gta_util::get_network()->m_game_session_ptr->m_peers[i];
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ namespace big
|
||||
[[nodiscard]] CVehicle* get_current_vehicle() const;
|
||||
[[nodiscard]] const char* get_name() const;
|
||||
[[nodiscard]] rage::rlGamerInfo* get_net_data() const;
|
||||
[[nodiscard]] int64_t get_rockstar_id() const;
|
||||
[[nodiscard]] CNetGamePlayer* get_net_game_player() const;
|
||||
[[nodiscard]] CPed* get_ped() const;
|
||||
[[nodiscard]] CPlayerInfo* get_player_info() const;
|
||||
|
@ -155,8 +155,8 @@ namespace big::chat
|
||||
g_file_manager.get_project_file(spam_reason != SpamReason::NOT_A_SPAMMER ? "./spam.log" : "./chat.log").get_path(),
|
||||
std::ios::app);
|
||||
|
||||
auto& data = *player->get_net_data();
|
||||
auto ip = player->get_ip_address();
|
||||
auto rockstar_id = player->get_rockstar_id();
|
||||
auto ip = player->get_ip_address();
|
||||
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()) % 1000;
|
||||
@ -174,10 +174,10 @@ namespace big::chat
|
||||
log << spam_reason_str << "[" << std::put_time(&local_time, "%m/%d/%Y %I:%M:%S") << ":" << std::setfill('0') << std::setw(3) << ms.count() << " " << std::put_time(&local_time, "%p") << "] ";
|
||||
|
||||
if (ip)
|
||||
log << player->get_name() << " (" << data.m_gamer_handle.m_rockstar_id << ") <" << (int)ip.value().m_field1 << "."
|
||||
log << player->get_name() << " (" << rockstar_id << ") <" << (int)ip.value().m_field1 << "."
|
||||
<< (int)ip.value().m_field2 << "." << (int)ip.value().m_field3 << "." << (int)ip.value().m_field4 << "> " << ((is_team == true) ? "[TEAM]: " : "[ALL]: ") << msg << std::endl;
|
||||
else
|
||||
log << player->get_name() << " (" << data.m_gamer_handle.m_rockstar_id << ") <UNKNOWN> " << ((is_team == true) ? "[TEAM]: " : "[ALL]: ") << msg << std::endl;
|
||||
log << player->get_name() << " (" << rockstar_id << ") <UNKNOWN> " << ((is_team == true) ? "[TEAM]: " : "[ALL]: ") << msg << std::endl;
|
||||
|
||||
log.close();
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ namespace big
|
||||
bool has_scrollbar = false;
|
||||
static void player_button(const player_ptr& plyr)
|
||||
{
|
||||
if (plyr == nullptr)
|
||||
if (plyr == nullptr || !plyr->is_valid())
|
||||
return;
|
||||
|
||||
bool selected_player = plyr == g_player_service->get_selected();
|
||||
@ -63,12 +63,9 @@ namespace big
|
||||
g_gui_service->set_selected(tabs::PLAYER);
|
||||
g.window.switched_view = true;
|
||||
}
|
||||
if (ImGui::IsItemHovered()
|
||||
&& g_player_database_service->get_player_by_rockstar_id(plyr->get_net_data()->m_gamer_handle.m_rockstar_id) != nullptr)
|
||||
if (auto rockstar_id = plyr->get_rockstar_id(); ImGui::IsItemHovered() && g_player_database_service->get_player_by_rockstar_id(rockstar_id) != nullptr)
|
||||
{
|
||||
auto sorted_player =
|
||||
g_player_database_service->get_player_by_rockstar_id(plyr->get_net_data()->m_gamer_handle.m_rockstar_id);
|
||||
|
||||
auto sorted_player = g_player_database_service->get_player_by_rockstar_id(rockstar_id);
|
||||
if (!sorted_player->infractions.empty())
|
||||
{
|
||||
ImGui::BeginTooltip();
|
||||
|
Loading…
Reference in New Issue
Block a user