TrinityCore
Loading...
Searching...
No Matches
InspectHandler.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "WorldSession.h"
19#include "InspectPackets.h"
20#include "Log.h"
21#include "ObjectAccessor.h"
22#include "Player.h"
23#include "World.h"
24
26{
28 if (!player)
29 {
30 TC_LOG_DEBUG("network", "WorldSession::HandleInspectOpcode: Target {} not found.", inspect.Target.ToString());
31 return;
32 }
33
34 TC_LOG_DEBUG("network", "WorldSession::HandleInspectOpcode: Target {}.", inspect.Target.ToString());
35
36 if (!GetPlayer()->IsWithinDistInMap(player, INSPECT_DISTANCE, false))
37 return;
38
39 if (GetPlayer()->IsValidAttackTarget(player))
40 return;
41
43 inspectResult.InspecteeGUID = inspect.Target;
44
45 for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i)
46 {
47 if (Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
48 {
49 inspectResult.ItemSlots[i] = true;
50 inspectResult.Items.emplace_back(item);
51 }
52 }
53
54 if (GetPlayer()->CanBeGameMaster() || sWorld->getIntConfig(CONFIG_TALENTS_INSPECTING) + (GetPlayer()->GetTeamId() == player->GetTeamId()) > 1)
55 player->BuildPlayerTalentsInfoData(inspectResult.TalentInfo);
56
57 SendPacket(inspectResult.Write());
58}
59
61{
63 if (!player)
64 {
65 TC_LOG_DEBUG("network", "WorldSession::HandleRequestHonorStatsOpcode: Target {} not found.", request.TargetGUID);
66 return;
67 }
68
69 TC_LOG_DEBUG("network", "WorldSession::HandleRequestHonorStatsOpcode: Target {}.", request.TargetGUID);
70
71 if (!GetPlayer()->IsWithinDistInMap(player, INSPECT_DISTANCE, false))
72 return;
73
74 if (GetPlayer()->IsValidAttackTarget(player))
75 return;
76
78 honorStats.PlayerGUID = request.TargetGUID;
85 SendPacket(honorStats.Write());
86}
87
89{
90 Player* player = ObjectAccessor::GetPlayer(*_player, inspect.Guid);
91 if (!player)
92 {
93 TC_LOG_DEBUG("network", "WorldSession::HandleQueryInspectAchievements: [{}] inspected unknown Player [{}]", GetPlayer()->GetGUID().ToString(), inspect.Guid.ToString());
94 return;
95 }
96
97 TC_LOG_DEBUG("network", "WorldSession::HandleQueryInspectAchievements: [{}] inspected Player [{}]", GetPlayer()->GetGUID().ToString(), inspect.Guid.ToString());
98
99 if (!GetPlayer()->IsWithinDistInMap(player, INSPECT_DISTANCE, false))
100 return;
101
102 if (GetPlayer()->IsValidAttackTarget(player))
103 return;
104
106}
uint8_t uint8
Definition Define.h:135
#define TC_LOG_DEBUG(filterType__,...)
Definition Log.h:156
#define INSPECT_DISTANCE
@ EQUIPMENT_SLOT_END
Definition Player.h:579
@ PLAYER_FIELD_BYTES_OFFSET_LIFETIME_MAX_PVP_RANK
Definition Player.h:409
@ PLAYER_FIELD_KILLS_OFFSET_TODAY_KILLS
Definition Player.h:444
@ PLAYER_FIELD_KILLS_OFFSET_YESTERDAY_KILLS
Definition Player.h:445
#define INVENTORY_SLOT_BAG_0
Definition Player.h:555
@ PLAYER_FIELD_TODAY_CONTRIBUTION
@ PLAYER_FIELD_KILLS
@ PLAYER_FIELD_YESTERDAY_CONTRIBUTION
@ PLAYER_FIELD_LIFETIME_HONORABLE_KILLS
@ PLAYER_FIELD_BYTES
Definition Item.h:62
std::string ToString() const
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition Object.cpp:259
uint32 GetUInt32Value(uint16 index) const
Definition Object.cpp:241
uint16 GetUInt16Value(uint16 index, uint8 offset) const
Definition Object.cpp:266
void BuildPlayerTalentsInfoData(WorldPackets::Talent::TalentInfoUpdate &talentInfo)
Definition Player.cpp:25228
Item * GetItemByPos(uint16 pos) const
Definition Player.cpp:9550
TeamId GetTeamId() const
Definition Player.h:1819
void SendRespondInspectAchievements(Player *player) const
Definition Player.cpp:24889
WorldPacket const * Write() override
WorldPacket const * Write() override
std::vector< InspectItemData > Items
Talent::TalentInfoUpdate TalentInfo
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
Player * GetPlayer() const
void HandleRequestHonorStats(WorldPackets::Inspect::RequestHonorStats &request)
void HandleQueryInspectAchievements(WorldPackets::Inspect::QueryInspectAchievements &inspect)
void HandleInspectOpcode(WorldPackets::Inspect::Inspect &inspect)
Player * _player
#define sWorld
Definition World.h:901
@ CONFIG_TALENTS_INSPECTING
Definition World.h:394
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)