fix(core/packets): reduce sending unnecessary packets (#13198)

Co-authored-by: Dehravor <dehravor@gmail.com>
This commit is contained in:
天鹿
2023-01-15 22:31:00 +08:00
committed by GitHub
parent 739165a197
commit 14885e3e96
2 changed files with 52 additions and 7 deletions

View File

@@ -34,15 +34,28 @@ void WorldSession::HandleInspectArenaTeamsOpcode(WorldPacket& recvData)
recvData >> guid;
LOG_DEBUG("network", "Inspect Arena stats ({})", guid.ToString());
if (Player* player = ObjectAccessor::FindPlayer(guid))
Player* player = ObjectAccessor::FindPlayer(guid);
if (!player)
{
for (uint8 i = 0; i < MAX_ARENA_SLOT; ++i)
return;
}
if (!GetPlayer()->IsWithinDistInMap(player, INSPECT_DISTANCE, false))
{
return;
}
if (GetPlayer()->IsValidAttackTarget(player))
{
return;
}
for (uint8 i = 0; i < MAX_ARENA_SLOT; ++i)
{
if (uint32 a_id = player->GetArenaTeamId(i))
{
if (uint32 a_id = player->GetArenaTeamId(i))
{
if (ArenaTeam* arenaTeam = sArenaTeamMgr->GetArenaTeamById(a_id))
arenaTeam->Inspect(this, player->GetGUID());
}
if (ArenaTeam* arenaTeam = sArenaTeamMgr->GetArenaTeamById(a_id))
arenaTeam->Inspect(this, player->GetGUID());
}
}
}

View File

@@ -1042,6 +1042,16 @@ void WorldSession::HandleInspectOpcode(WorldPacket& recv_data)
return;
}
if (!GetPlayer()->IsWithinDistInMap(player, INSPECT_DISTANCE, false))
{
return;
}
if (GetPlayer()->IsValidAttackTarget(player))
{
return;
}
uint32 talent_points = 0x47;
uint32 guid_size = player->GetPackGUID().size();
WorldPacket data(SMSG_INSPECT_TALENT, guid_size + 4 + talent_points);
@@ -1074,6 +1084,16 @@ void WorldSession::HandleInspectHonorStatsOpcode(WorldPacket& recv_data)
return;
}
if (!GetPlayer()->IsWithinDistInMap(player, INSPECT_DISTANCE, false))
{
return;
}
if (GetPlayer()->IsValidAttackTarget(player))
{
return;
}
WorldPacket data(MSG_INSPECT_HONOR_STATS, 8 + 1 + 4 * 4);
data << player->GetGUID();
data << uint8(player->GetHonorPoints());
@@ -1608,7 +1628,19 @@ void WorldSession::HandleQueryInspectAchievements(WorldPacket& recv_data)
Player* player = ObjectAccessor::GetPlayer(*_player, guid);
if (!player)
{
return;
}
if (!GetPlayer()->IsWithinDistInMap(player, INSPECT_DISTANCE, false))
{
return;
}
if (GetPlayer()->IsValidAttackTarget(player))
{
return;
}
player->SendRespondInspectAchievements(_player);
}