TrinityCore
Loading...
Searching...
No Matches
Account.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 "Account.h"
19#include "Map.h"
20#include "Player.h"
21#include "StringFormat.h"
22#include "WorldSession.h"
23
24namespace Battlenet
25{
26Account::Account(WorldSession* session, ObjectGuid guid, std::string&& name) : m_session(session), m_name(std::move(name))
27{
28 _Create(guid);
29
31
32 // Default value
34}
35
36std::string Account::GetNameForLocaleIdx(LocaleConstant /*locale*/) const
37{
38 return m_name;
39}
40
42{
44
45 if (Player* owner = m_session->GetPlayer())
46 BuildFieldsUpdate(owner, data_map);
47
48 ClearUpdateMask(false);
49}
50
51std::string Account::GetDebugInfo() const
52{
53 return Trinity::StringFormat("{}\nName: {}", BaseEntity::GetDebugInfo(), m_name);
54}
55
57{
58 if (*target->m_playerData->BnetAccount == GetGUID())
60
62}
63
65{
66 if (Player* owner = m_session->GetPlayer(); owner && owner->IsInWorld())
67 {
68 owner->GetMap()->AddUpdateObject(this);
69 return true;
70 }
71
72 return false;
73}
74
76{
77 if (Player* owner = m_session->GetPlayer(); owner && owner->IsInWorld())
78 owner->GetMap()->RemoveUpdateObject(this);
79}
80}
std::unordered_map< Player *, UpdateData > UpdateDataMapType
Definition BaseEntity.h:32
LocaleConstant
Definition Common.h:51
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
void BuildUpdateChangesMask()
void SetUpdateFieldValue(UF::UpdateFieldPrivateSetter< T > setter, typename UF::UpdateFieldPrivateSetter< T >::value_type value)
Definition BaseEntity.h:221
virtual std::string GetDebugInfo() const
WowCS::EntityFragmentsHolder m_entityFragments
Definition BaseEntity.h:353
UF::UpdateFieldHolder m_values
Definition BaseEntity.h:205
void _Create(ObjectGuid const &guid)
Definition BaseEntity.h:218
void ClearUpdateMask(bool remove)
void BuildFieldsUpdate(Player *player, UpdateDataMapType &data_map) const
std::string m_name
Definition Account.h:48
UF::UpdateField< UF::HousingStorageData, int32(WowCS::EntityFragment::FHousingStorage_C), 0 > m_housingStorageData
Definition Account.h:38
bool AddToObjectUpdate() override
Definition Account.cpp:64
std::string GetDebugInfo() const override
Definition Account.cpp:51
WorldSession * m_session
Definition Account.h:47
void BuildUpdate(UpdateDataMapType &data_map) override
Definition Account.cpp:41
void RemoveFromObjectUpdate() override
Definition Account.cpp:75
std::string GetNameForLocaleIdx(LocaleConstant locale) const override
Definition Account.cpp:36
UF::UpdateFieldFlag GetUpdateFieldFlagsFor(Player const *target) const override
Definition Account.cpp:56
Account(WorldSession *session, ObjectGuid guid, std::string &&name)
Definition Account.cpp:26
UF::UpdateField< UF::PlayerData, int32(WowCS::EntityFragment::CGObject), TYPEID_PLAYER > m_playerData
Definition Player.h:3061
MutableFieldReference< T, false > ModifyValue(UpdateField< T, BlockBit, Bit >(Derived::*field))
Player session in the World.
Player * GetPlayer() const
std::string StringFormat(FormatString< Args... > fmt, Args &&... args) noexcept
Default TC string format function.
UpdateFieldFlag
Definition UpdateField.h:37
void const * GetRawFragmentData(T const &fragmentData)
STL namespace.
UpdateField< uint32, 0, 2 > DecorMaxOwnedCount
void Add(EntityFragment fragment, bool update, void const *data=nullptr)