fix(PlayerJoin): don't notify above map while joining (#482)

This commit is contained in:
Yimura 2022-10-19 22:27:01 +02:00 committed by GitHub
parent 392883e3b0
commit d3b88e1a35

View File

@ -6,36 +6,41 @@ namespace big
{
void* hooks::assign_physical_index(CNetworkPlayerMgr* netPlayerMgr, CNetGamePlayer* player, uint8_t new_index)
{
auto returnResult = g_hooking->m_assign_physical_index_hook.get_original<decltype(&hooks::assign_physical_index)>()(netPlayerMgr, player, new_index);
if (new_index == 0xFF) {
const auto result = g_hooking->m_assign_physical_index_hook.get_original<decltype(&hooks::assign_physical_index)>()(netPlayerMgr, player, new_index);
const auto* net_player_data = player->get_net_data();
if (new_index == static_cast<uint8_t>(-1))
{
g_player_service->player_leave(player);
if (const auto* net_player_data = player->get_net_data(); net_player_data)
if (net_player_data)
{
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_2.m_rockstar_id;
<< "' freeing slot #" << (int)player->m_player_id
<< " with Rockstar ID: " << net_player_data->m_gamer_handle_2.m_rockstar_id;
if (g->notifications.player_leave.notify)
g_notification_service->push("Player Left", fmt::format("{} freeing slot #{} with Rockstar ID: {}", net_player_data->m_name, player->m_player_id, net_player_data->m_gamer_handle_2.m_rockstar_id));
}
return returnResult;
return result;
}
g_player_service->player_join(player);
if (const auto* net_player_data = player->get_net_data(); net_player_data)
if (net_player_data)
{
if (g->notifications.player_join.above_map)
if (g->notifications.player_join.above_map && *g_pointers->m_is_session_started) // prevent loading screen spam
notify::player_joined(player);
if (g->notifications.player_join.log)
LOG(INFO) << "Player joined '" << net_player_data->m_name
<< "' allocating slot #" << (int)player->m_player_id
<< " with Rockstar ID: " << net_player_data->m_gamer_handle_2.m_rockstar_id;
<< "' allocating slot #" << (int)player->m_player_id
<< " with Rockstar ID: " << net_player_data->m_gamer_handle_2.m_rockstar_id;
if (g->notifications.player_join.notify)
g_notification_service->push("Player Joined", fmt::format("{} taking slot #{} with Rockstar ID: {}", net_player_data->m_name, player->m_player_id, net_player_data->m_gamer_handle_2.m_rockstar_id));
}
return returnResult;
return result;
}
}