TrinityCore
Loading...
Searching...
No Matches
Guild Class Reference

#include <Guild.h>

Classes

class  BankEventLogEntry
 
class  BankMoveItemData
 
class  BankTab
 
class  EventLogEntry
 
class  LogEntry
 
class  LogHolder
 
class  Member
 
class  MoveItemData
 
class  NewsLogEntry
 
class  PlayerMoveItemData
 
class  RankInfo
 

Public Member Functions

 Guild ()
 
 ~Guild ()
 
bool Create (Player *pLeader, std::string_view name)
 
void Disband ()
 
void SaveToDB ()
 
ObjectGuid::LowType GetId () const
 
ObjectGuid GetGUID () const
 
ObjectGuid GetLeaderGUID () const
 
std::string const & GetName () const
 
std::string const & GetMOTD () const
 
std::string const & GetInfo () const
 
time_t GetCreatedDate () const
 
uint64 GetBankMoney () const
 
bool SetName (std::string_view name)
 
void HandleRoster (WorldSession *session)
 
void SendQueryResponse (WorldSession *session)
 
void HandleSetAchievementTracking (WorldSession *session, uint32 const *achievementIdsBegin, uint32 const *achievementIdsEnd)
 
void HandleGetAchievementMembers (WorldSession *session, uint32 achievementId) const
 
void HandleSetMOTD (WorldSession *session, std::string_view motd)
 
void HandleSetInfo (WorldSession *session, std::string_view info)
 
void HandleSetEmblem (WorldSession *session, EmblemInfo const &emblemInfo)
 
void HandleSetNewGuildMaster (WorldSession *session, std::string_view name, bool isSelfPromote)
 
void HandleSetBankTabInfo (WorldSession *session, uint8 tabId, std::string_view name, std::string_view icon)
 
void HandleSetMemberNote (WorldSession *session, std::string_view note, ObjectGuid guid, bool isPublic)
 
void HandleSetRankInfo (WorldSession *session, GuildRankId rankId, std::string_view name, uint32 rights, uint32 moneyPerDay, std::array< GuildBankRightsAndSlots, GUILD_BANK_MAX_TABS > const &rightsAndSlots)
 
void HandleBuyBankTab (WorldSession *session, uint8 tabId)
 
void HandleInviteMember (WorldSession *session, std::string_view name)
 
void HandleAcceptMember (WorldSession *session)
 
void HandleLeaveMember (WorldSession *session)
 
void HandleRemoveMember (WorldSession *session, ObjectGuid guid)
 
void HandleUpdateMemberRank (WorldSession *session, ObjectGuid guid, bool demote)
 
void HandleSetMemberRank (WorldSession *session, ObjectGuid guid, ObjectGuid setterGuid, GuildRankOrder rank)
 
void HandleAddNewRank (WorldSession *session, std::string_view name)
 
void HandleRemoveRank (WorldSession *session, GuildRankOrder rankOrder)
 
void HandleShiftRank (WorldSession *session, GuildRankOrder rankOrder, bool shiftUp)
 
void HandleMemberDepositMoney (WorldSession *session, uint64 amount, bool cashFlow=false)
 
bool HandleMemberWithdrawMoney (WorldSession *session, uint64 amount, bool repair=false)
 
void HandleMemberLogout (WorldSession *session)
 
void HandleDelete (WorldSession *session)
 
void HandleGuildPartyRequest (WorldSession *session) const
 
void HandleNewsSetSticky (WorldSession *session, uint32 newsId, bool sticky)
 
void HandleGuildRequestChallengeUpdate (WorldSession *session) const
 
void UpdateMemberData (Player *player, uint8 dataid, uint32 value)
 
void OnPlayerStatusChange (Player *player, uint32 flag, bool state)
 
void SendGuildRankInfo (WorldSession *session) const
 
void SendEventLog (WorldSession *session) const
 
void SendBankLog (WorldSession *session, uint8 tabId) const
 
void SendBankList (WorldSession *session, uint8 tabId, bool fullUpdate) const
 
void SendBankTabText (WorldSession *session, uint8 tabId) const
 
void SendPermissions (WorldSession *session) const
 
void SendMoneyInfo (WorldSession *session) const
 
void SendLoginInfo (WorldSession *session)
 
void SendNewsUpdate (WorldSession *session) const
 
void SendEventAwayChanged (ObjectGuid const &memberGuid, bool afk, bool dnd)
 
void SendEventBankMoneyChanged () const
 
void SendEventMOTD (WorldSession *session, bool broadcast=false) const
 
void SendEventNewLeader (Member *newLeader, Member *oldLeader, bool isSelfPromoted=false) const
 
void SendEventPlayerLeft (Member *leaver, Member *remover=nullptr, bool isRemoved=false) const
 
void SendEventPresenceChanged (WorldSession *session, bool loggedOn, bool broadcast=false) const
 
bool LoadFromDB (Field *fields)
 
void LoadGuildNewsLogFromDB (Field *fields)
 
void LoadRankFromDB (Field *fields)
 
bool LoadMemberFromDB (Field *fields)
 
bool LoadEventLogFromDB (Field *fields)
 
void LoadBankRightFromDB (Field *fields)
 
void LoadBankTabFromDB (Field *fields)
 
bool LoadBankEventLogFromDB (Field *fields)
 
bool LoadBankItemFromDB (Field *fields)
 
bool Validate ()
 
void BroadcastToGuild (WorldSession *session, bool officerOnly, std::string_view msg, uint32 language=LANG_UNIVERSAL) const
 
void BroadcastAddonToGuild (WorldSession *session, bool officerOnly, std::string_view msg, std::string_view prefix, bool isLogged) const
 
void BroadcastPacketToRank (WorldPacket const *packet, GuildRankId rankId) const
 
void BroadcastPacket (WorldPacket const *packet) const
 
void BroadcastPacketIfTrackingAchievement (WorldPacket const *packet, uint32 criteriaId) const
 
void MassInviteToEvent (WorldSession *session, uint32 minLevel, uint32 maxLevel, GuildRankOrder minRank)
 
template<class Do >
void BroadcastWorker (Do &_do, Player *except=nullptr)
 
bool AddMember (CharacterDatabaseTransaction trans, ObjectGuid guid, Optional< GuildRankId > rankId={})
 
void DeleteMember (CharacterDatabaseTransaction trans, ObjectGuid guid, bool isDisbanding=false, bool isKicked=false, bool canDeleteGuild=false)
 
bool ChangeMemberRank (CharacterDatabaseTransaction trans, ObjectGuid guid, GuildRankId newRank)
 
bool IsMember (ObjectGuid guid) const
 
uint32 GetMembersCount () const
 
uint64 GetMemberAvailableMoneyForRepairItems (ObjectGuid guid) const
 
void SwapItems (Player *player, uint8 tabId, uint8 slotId, uint8 destTabId, uint8 destSlotId, uint32 splitedAmount)
 
void SwapItemsWithInventory (Player *player, bool toChar, uint8 tabId, uint8 slotId, uint8 playerBag, uint8 playerSlotId, uint32 splitedAmount)
 
void SetBankTabText (uint8 tabId, std::string_view text)
 
GuildAchievementMgrGetAchievementMgr ()
 
GuildAchievementMgr const & GetAchievementMgr () const
 
uint8 GetLevel () const
 
void AddGuildNews (uint8 type, ObjectGuid guid, uint32 flags, uint32 value)
 
EmblemInfo const & GetEmblemInfo () const
 
void ResetTimes (bool weekly)
 
bool HasAchieved (uint32 achievementId) const
 
void UpdateCriteria (CriteriaType type, uint64 miscValue1, uint64 miscValue2, uint64 miscValue3, WorldObject const *ref, Player *player)
 

Static Public Member Functions

static void SendCommandResult (WorldSession *session, GuildCommandType type, GuildCommandError errCode, std::string_view param="")
 
static void SendSaveEmblemResult (WorldSession *session, GuildEmblemError errCode)
 

Protected Attributes

ObjectGuid::LowType m_id
 
std::string m_name
 
ObjectGuid m_leaderGuid
 
std::string m_motd
 
std::string m_info
 
time_t m_createdDate
 
EmblemInfo m_emblemInfo
 
uint32 m_accountsNumber
 
uint64 m_bankMoney
 
std::vector< RankInfom_ranks
 
std::unordered_map< ObjectGuid, Memberm_members
 
std::vector< BankTabm_bankTabs
 
LogHolder< EventLogEntrym_eventLog
 
std::array< LogHolder< BankEventLogEntry >, GUILD_BANK_MAX_TABS+1 > m_bankEventLog = {}
 
LogHolder< NewsLogEntrym_newsLog
 
std::unique_ptr< GuildAchievementMgrm_achievementMgr
 

Private Member Functions

uint8 _GetRanksSize () const
 
RankInfo const * GetRankInfo (GuildRankId rankId) const
 
RankInfoGetRankInfo (GuildRankId rankId)
 
RankInfo const * GetRankInfo (GuildRankOrder rankOrder) const
 
RankInfoGetRankInfo (GuildRankOrder rankOrder)
 
bool _HasRankRight (Player const *player, uint32 right) const
 
GuildRankId _GetLowestRankId () const
 
uint8 _GetPurchasedTabsSize () const
 
BankTabGetBankTab (uint8 tabId)
 
BankTab const * GetBankTab (uint8 tabId) const
 
Member const * GetMember (ObjectGuid const &guid) const
 
MemberGetMember (ObjectGuid const &guid)
 
MemberGetMember (std::string_view name)
 
void _CreateNewBankTab ()
 
void _CreateDefaultGuildRanks (CharacterDatabaseTransaction trans, LocaleConstant loc)
 
bool _CreateRank (CharacterDatabaseTransaction trans, std::string_view name, uint32 rights)
 
void _UpdateAccountsNumber ()
 
bool _IsLeader (Player *player) const
 
void _DeleteBankItems (CharacterDatabaseTransaction trans, bool removeItemsFromDB=false)
 
bool _ModifyBankMoney (CharacterDatabaseTransaction trans, uint64 amount, bool add)
 
void _SetLeader (CharacterDatabaseTransaction trans, Member &leader)
 
void _SetRankBankMoneyPerDay (GuildRankId rankId, uint32 moneyPerDay)
 
void _SetRankBankTabRightsAndSlots (GuildRankId rankId, GuildBankRightsAndSlots rightsAndSlots, bool saveToDB=true)
 
int8 _GetRankBankTabRights (GuildRankId rankId, uint8 tabId) const
 
uint32 _GetRankRights (GuildRankId rankId) const
 
uint32 _GetRankBankMoneyPerDay (GuildRankId rankId) const
 
int32 _GetRankBankTabSlotsPerDay (GuildRankId rankId, uint8 tabId) const
 
std::string _GetRankName (GuildRankId rankId) const
 
int32 _GetMemberRemainingSlots (Member const &member, uint8 tabId) const
 
int64 _GetMemberRemainingMoney (Member const &member) const
 
void _UpdateMemberWithdrawSlots (CharacterDatabaseTransaction trans, ObjectGuid guid, uint8 tabId)
 
bool _MemberHasTabRights (ObjectGuid guid, uint8 tabId, int32 rights) const
 
void _LogEvent (GuildEventLogTypes eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2=UI64LIT(0), uint8 newRank=0)
 
void _LogBankEvent (CharacterDatabaseTransaction trans, GuildBankEventLogTypes eventType, uint8 tabId, ObjectGuid::LowType playerGuid, uint64 itemOrMoney, uint16 itemStackCount=0, uint8 destTabId=0)
 
Item_GetItem (uint8 tabId, uint8 slotId) const
 
void _RemoveItem (CharacterDatabaseTransaction trans, uint8 tabId, uint8 slotId)
 
void _MoveItems (MoveItemData *pSrc, MoveItemData *pDest, uint32 splitedAmount) const
 
void _SendBankContentUpdate (MoveItemData *pSrc, MoveItemData *pDest) const
 
void _SendBankContentUpdate (uint8 tabId, SlotIds slots) const
 
void SendGuildRanksUpdate (ObjectGuid setterGuid, ObjectGuid targetGuid, GuildRankId rank)
 

Static Private Member Functions

static void _DeleteMemberFromDB (CharacterDatabaseTransaction trans, ObjectGuid::LowType lowguid)
 
static InventoryResult _DoItemsMove (MoveItemData *pSrc, MoveItemData *pDest, bool sendError, uint32 splitedAmount=0)
 

Detailed Description

Definition at line 305 of file Guild.h.

Constructor & Destructor Documentation

◆ Guild()

Guild::Guild ( )

Definition at line 1114 of file Guild.cpp.

1114 :
1115 m_id(UI64LIT(0)),
1116 m_leaderGuid(),
1117 m_createdDate(0),
1119 m_bankMoney(0),
1120 m_achievementMgr(std::make_unique<GuildAchievementMgr>(this))
1121{
1122}
#define UI64LIT(N)
Definition: Define.h:128
uint64 m_bankMoney
Definition: Guild.h:862
std::unique_ptr< GuildAchievementMgr > m_achievementMgr
Definition: Guild.h:872
uint32 m_accountsNumber
Definition: Guild.h:861
time_t m_createdDate
Definition: Guild.h:858
ObjectGuid m_leaderGuid
Definition: Guild.h:855
ObjectGuid::LowType m_id
Definition: Guild.h:853

◆ ~Guild()

Guild::~Guild ( )

Definition at line 1124 of file Guild.cpp.

1125{
1126 CharacterDatabaseTransaction temp(nullptr);
1127 _DeleteBankItems(temp);
1128}
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
void _DeleteBankItems(CharacterDatabaseTransaction trans, bool removeItemsFromDB=false)
Definition: Guild.cpp:3104
+ Here is the call graph for this function:

Member Function Documentation

◆ _CreateDefaultGuildRanks()

void Guild::_CreateDefaultGuildRanks ( CharacterDatabaseTransaction  trans,
LocaleConstant  loc 
)
private

Definition at line 3030 of file Guild.cpp.

3031{
3032 ASSERT(trans);
3033
3035 stmt->setUInt64(0, m_id);
3036 trans->Append(stmt);
3037
3038 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_RIGHTS);
3039 stmt->setUInt64(0, m_id);
3040 trans->Append(stmt);
3041
3042 _CreateRank(trans, sObjectMgr->GetTrinityString(LANG_GUILD_MASTER, loc), GR_RIGHT_ALL);
3043 _CreateRank(trans, sObjectMgr->GetTrinityString(LANG_GUILD_OFFICER, loc), GR_RIGHT_ALL);
3047}
@ CHAR_DEL_GUILD_BANK_RIGHTS
@ CHAR_DEL_GUILD_RANKS
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define ASSERT
Definition: Errors.h:68
@ GR_RIGHT_GCHATSPEAK
Definition: Guild.h:87
@ GR_RIGHT_ALL
Definition: Guild.h:107
@ GR_RIGHT_GCHATLISTEN
Definition: Guild.h:86
@ LANG_GUILD_MASTER
Definition: Language.h:763
@ LANG_GUILD_VETERAN
Definition: Language.h:765
@ LANG_GUILD_OFFICER
Definition: Language.h:764
@ LANG_GUILD_INITIATE
Definition: Language.h:767
@ LANG_GUILD_MEMBER
Definition: Language.h:766
#define sObjectMgr
Definition: ObjectMgr.h:1952
bool _CreateRank(CharacterDatabaseTransaction trans, std::string_view name, uint32 rights)
Definition: Guild.cpp:3049
void setUInt64(const uint8 index, const uint64 value)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _CreateNewBankTab()

void Guild::_CreateNewBankTab ( )
private

Definition at line 3006 of file Guild.cpp.

3007{
3008 uint8 tabId = _GetPurchasedTabsSize(); // Next free id
3009 m_bankTabs.emplace_back(m_id, tabId);
3010
3011 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
3012
3014 stmt->setUInt64(0, m_id);
3015 stmt->setUInt8 (1, tabId);
3016 trans->Append(stmt);
3017
3018 stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD_BANK_TAB);
3019 stmt->setUInt64(0, m_id);
3020 stmt->setUInt8 (1, tabId);
3021 trans->Append(stmt);
3022
3023 ++tabId;
3024 for (auto itr = m_ranks.begin(); itr != m_ranks.end(); ++itr)
3025 (*itr).CreateMissingTabsIfNeeded(tabId, trans, false);
3026
3027 CharacterDatabase.CommitTransaction(trans);
3028}
@ CHAR_INS_GUILD_BANK_TAB
@ CHAR_DEL_GUILD_BANK_TAB
uint8_t uint8
Definition: Define.h:145
std::vector< BankTab > m_bankTabs
Definition: Guild.h:866
uint8 _GetPurchasedTabsSize() const
Definition: Guild.h:884
std::vector< RankInfo > m_ranks
Definition: Guild.h:864
void setUInt8(const uint8 index, const uint8 value)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _CreateRank()

bool Guild::_CreateRank ( CharacterDatabaseTransaction  trans,
std::string_view  name,
uint32  rights 
)
private

Definition at line 3049 of file Guild.cpp.

3050{
3051 if (m_ranks.size() >= GUILD_RANKS_MAX_COUNT)
3052 return false;
3053
3054 uint8 newRankId = [&]()
3055 {
3056 uint8 freeRankId = 0;
3057 while (GetRankInfo(GuildRankId(freeRankId)))
3058 ++freeRankId;
3059
3060 return freeRankId;
3061 }();
3062
3063 // Ranks represent sequence 0, 1, 2, ... where 0 means guildmaster
3064 RankInfo info(m_id, GuildRankId(newRankId), GuildRankOrder(m_ranks.size()), name, rights, 0);
3065 m_ranks.push_back(info);
3066
3067 bool const isInTransaction = bool(trans);
3068 if (!isInTransaction)
3069 trans = CharacterDatabase.BeginTransaction();
3070
3071 info.CreateMissingTabsIfNeeded(_GetPurchasedTabsSize(), trans);
3072 info.SaveToDB(trans);
3073
3074 if (!isInTransaction)
3075 CharacterDatabase.CommitTransaction(trans);
3076
3077 return true;
3078}
@ GUILD_RANKS_MAX_COUNT
Definition: Guild.h:58
GuildRankOrder
Definition: Guild.h:81
GuildRankId
Definition: Guild.h:77
RankInfo const * GetRankInfo(GuildRankId rankId) const
Definition: Guild.cpp:2950
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _DeleteBankItems()

void Guild::_DeleteBankItems ( CharacterDatabaseTransaction  trans,
bool  removeItemsFromDB = false 
)
private

Definition at line 3104 of file Guild.cpp.

3105{
3106 for (uint8 tabId = 0; tabId < _GetPurchasedTabsSize(); ++tabId)
3107 m_bankTabs[tabId].Delete(trans, removeItemsFromDB);
3108
3109 m_bankTabs.clear();
3110}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _DeleteMemberFromDB()

void Guild::_DeleteMemberFromDB ( CharacterDatabaseTransaction  trans,
ObjectGuid::LowType  lowguid 
)
staticprivate

Definition at line 2998 of file Guild.cpp.

2999{
3001 stmt->setUInt64(0, lowguid);
3002 CharacterDatabase.ExecuteOrAppend(trans, stmt);
3003}
@ CHAR_DEL_GUILD_MEMBER
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _DoItemsMove()

InventoryResult Guild::_DoItemsMove ( MoveItemData pSrc,
MoveItemData pDest,
bool  sendError,
uint32  splitedAmount = 0 
)
staticprivate

Definition at line 3351 of file Guild.cpp.

3352{
3353 Item* pDestItem = pDest->GetItem();
3354 bool swap = (pDestItem != nullptr);
3355
3356 Item* pSrcItem = pSrc->GetItem(splitedAmount != 0);
3357 // 1. Can store source item in destination
3358 InventoryResult destResult = pDest->CanStore(pSrcItem, swap, sendError);
3359 if (destResult != EQUIP_ERR_OK)
3360 return destResult;
3361
3362 // 2. Can store destination item in source
3363 if (swap)
3364 {
3365 InventoryResult srcResult = pSrc->CanStore(pDestItem, true, true);
3366 if (srcResult != EQUIP_ERR_OK)
3367 return srcResult;
3368 }
3369
3370 // GM LOG (@todo move to scripts)
3371 pDest->LogAction(pSrc);
3372 if (swap)
3373 pSrc->LogAction(pDest);
3374
3375 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
3376 // 3. Log bank events
3377 pDest->LogBankEvent(trans, pSrc, pSrcItem->GetCount());
3378 if (swap)
3379 pSrc->LogBankEvent(trans, pDest, pDestItem->GetCount());
3380
3381 // 4. Remove item from source
3382 pSrc->RemoveItem(trans, pDest, splitedAmount);
3383
3384 // 5. Remove item from destination
3385 if (swap)
3386 pDest->RemoveItem(trans, pSrc);
3387
3388 // 6. Store item in destination
3389 pDest->StoreItem(trans, pSrcItem);
3390
3391 // 7. Store item in source
3392 if (swap)
3393 pSrc->StoreItem(trans, pDestItem);
3394
3395 CharacterDatabase.CommitTransaction(trans);
3396 return EQUIP_ERR_OK;
3397}
InventoryResult
Definition: ItemDefines.h:25
@ EQUIP_ERR_OK
Definition: ItemDefines.h:26
Definition: Item.h:170
uint32 GetCount() const
Definition: Item.h:273
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _GetItem()

Item * Guild::_GetItem ( uint8  tabId,
uint8  slotId 
) const
inlineprivate

Definition at line 3281 of file Guild.cpp.

3282{
3283 if (BankTab const* tab = GetBankTab(tabId))
3284 return tab->GetItem(slotId);
3285 return nullptr;
3286}
BankTab * GetBankTab(uint8 tabId)
Definition: Guild.h:885
+ Here is the call graph for this function:

◆ _GetLowestRankId()

GuildRankId Guild::_GetLowestRankId ( ) const
inlineprivate

Definition at line 882 of file Guild.h.

882{ return m_ranks.back().GetId(); }
+ Here is the caller graph for this function:

◆ _GetMemberRemainingMoney()

int64 Guild::_GetMemberRemainingMoney ( Member const &  member) const
inlineprivate

Definition at line 3216 of file Guild.cpp.

3217{
3218 GuildRankId rankId = member.GetRankId();
3219 if (rankId == GuildRankId::GuildMaster)
3220 return std::numeric_limits<int64>::max();
3221
3223 {
3224 int64 remaining = _GetRankBankMoneyPerDay(rankId) - member.GetBankMoneyWithdrawValue();
3225 if (remaining > 0)
3226 return remaining;
3227 }
3228 return 0;
3229}
int64_t int64
Definition: Define.h:138
@ GR_RIGHT_WITHDRAW_REPAIR
Definition: Guild.h:104
@ GR_RIGHT_WITHDRAW_GOLD
Definition: Guild.h:105
uint32 _GetRankBankMoneyPerDay(GuildRankId rankId) const
Definition: Guild.cpp:3178
uint32 _GetRankRights(GuildRankId rankId) const
Definition: Guild.cpp:3171
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _GetMemberRemainingSlots()

int32 Guild::_GetMemberRemainingSlots ( Member const &  member,
uint8  tabId 
) const
inlineprivate

Definition at line 3200 of file Guild.cpp.

3201{
3202 GuildRankId rankId = member.GetRankId();
3203 if (rankId == GuildRankId::GuildMaster)
3204 return static_cast<int32>(GUILD_WITHDRAW_SLOT_UNLIMITED);
3205 if ((_GetRankBankTabRights(rankId, tabId) & GUILD_BANK_RIGHT_VIEW_TAB) != 0)
3206 {
3207
3208 int32 remaining = _GetRankBankTabSlotsPerDay(rankId, tabId) - member.GetBankTabWithdrawValue(tabId);
3209 if (remaining > 0)
3210 return remaining;
3211
3212 }
3213 return 0;
3214}
int32_t int32
Definition: Define.h:139
@ GUILD_WITHDRAW_SLOT_UNLIMITED
Definition: Guild.h:61
@ GUILD_BANK_RIGHT_VIEW_TAB
Definition: Guild.h:168
int8 _GetRankBankTabRights(GuildRankId rankId, uint8 tabId) const
Definition: Guild.cpp:3193
int32 _GetRankBankTabSlotsPerDay(GuildRankId rankId, uint8 tabId) const
Definition: Guild.cpp:3185
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _GetPurchasedTabsSize()

uint8 Guild::_GetPurchasedTabsSize ( ) const
inlineprivate

Definition at line 884 of file Guild.h.

884{ return uint8(m_bankTabs.size()); }
+ Here is the caller graph for this function:

◆ _GetRankBankMoneyPerDay()

uint32 Guild::_GetRankBankMoneyPerDay ( GuildRankId  rankId) const
inlineprivate

Definition at line 3178 of file Guild.cpp.

3179{
3180 if (RankInfo const* rankInfo = GetRankInfo(rankId))
3181 return rankInfo->GetBankMoneyPerDay();
3182 return 0;
3183}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _GetRankBankTabRights()

int8 Guild::_GetRankBankTabRights ( GuildRankId  rankId,
uint8  tabId 
) const
inlineprivate

Definition at line 3193 of file Guild.cpp.

3194{
3195 if (RankInfo const* rankInfo = GetRankInfo(rankId))
3196 return rankInfo->GetBankTabRights(tabId);
3197 return 0;
3198}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _GetRankBankTabSlotsPerDay()

int32 Guild::_GetRankBankTabSlotsPerDay ( GuildRankId  rankId,
uint8  tabId 
) const
inlineprivate

Definition at line 3185 of file Guild.cpp.

3186{
3187 if (tabId < _GetPurchasedTabsSize())
3188 if (RankInfo const* rankInfo = GetRankInfo(rankId))
3189 return rankInfo->GetBankTabSlotsPerDay(tabId);
3190 return 0;
3191}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _GetRankName()

std::string Guild::_GetRankName ( GuildRankId  rankId) const
inlineprivate

Definition at line 3164 of file Guild.cpp.

3165{
3166 if (RankInfo const* rankInfo = GetRankInfo(rankId))
3167 return rankInfo->GetName();
3168 return "<unknown>";
3169}
+ Here is the call graph for this function:

◆ _GetRankRights()

uint32 Guild::_GetRankRights ( GuildRankId  rankId) const
inlineprivate

Definition at line 3171 of file Guild.cpp.

3172{
3173 if (RankInfo const* rankInfo = GetRankInfo(rankId))
3174 return rankInfo->GetRights();
3175 return 0;
3176}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _GetRanksSize()

uint8 Guild::_GetRanksSize ( ) const
inlineprivate

Definition at line 875 of file Guild.h.

875{ return uint8(m_ranks.size()); }
+ Here is the caller graph for this function:

◆ _HasRankRight()

bool Guild::_HasRankRight ( Player const *  player,
uint32  right 
) const
private

Definition at line 2990 of file Guild.cpp.

2991{
2992 if (player)
2993 if (Member const* member = GetMember(player->GetGUID()))
2994 return (_GetRankRights(member->GetRankId()) & right) != GR_RIGHT_NONE;
2995 return false;
2996}
@ GR_RIGHT_NONE
Definition: Guild.h:85
Member const * GetMember(ObjectGuid const &guid) const
Definition: Guild.h:888
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _IsLeader()

bool Guild::_IsLeader ( Player player) const
private

Definition at line 3095 of file Guild.cpp.

3096{
3097 if (player->GetGUID() == m_leaderGuid)
3098 return true;
3099 if (Member const* member = GetMember(player->GetGUID()))
3100 return member->IsRank(GuildRankId::GuildMaster);
3101 return false;
3102}
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:158
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _LogBankEvent()

void Guild::_LogBankEvent ( CharacterDatabaseTransaction  trans,
GuildBankEventLogTypes  eventType,
uint8  tabId,
ObjectGuid::LowType  playerGuid,
uint64  itemOrMoney,
uint16  itemStackCount = 0,
uint8  destTabId = 0 
)
private

Definition at line 3260 of file Guild.cpp.

3261{
3262 if (tabId > GUILD_BANK_MAX_TABS)
3263 return;
3264
3265 // not logging moves within the same tab
3266 if (eventType == GUILD_BANK_LOG_MOVE_ITEM && tabId == destTabId)
3267 return;
3268
3269 uint8 dbTabId = tabId;
3270 if (BankEventLogEntry::IsMoneyEvent(eventType))
3271 {
3272 tabId = GUILD_BANK_MAX_TABS;
3273 dbTabId = GUILD_BANK_MONEY_LOGS_TAB;
3274 }
3275 LogHolder<BankEventLogEntry>& pLog = m_bankEventLog[tabId];
3276 pLog.AddEvent(trans, m_id, pLog.GetNextGUID(), eventType, dbTabId, lowguid, itemOrMoney, itemStackCount, destTabId);
3277
3278 sScriptMgr->OnGuildBankEvent(this, uint8(eventType), tabId, lowguid, itemOrMoney, itemStackCount, destTabId);
3279}
@ GUILD_BANK_MONEY_LOGS_TAB
Definition: Guild.h:55
@ GUILD_BANK_MAX_TABS
Definition: Guild.h:53
@ GUILD_BANK_LOG_MOVE_ITEM
Definition: Guild.h:180
#define sScriptMgr
Definition: ScriptMgr.h:1418
bool IsMoneyEvent() const
Definition: Guild.h:455
std::array< LogHolder< BankEventLogEntry >, GUILD_BANK_MAX_TABS+1 > m_bankEventLog
Definition: Guild.h:870
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _LogEvent()

void Guild::_LogEvent ( GuildEventLogTypes  eventType,
ObjectGuid::LowType  playerGuid1,
ObjectGuid::LowType  playerGuid2 = UI64LIT(0),
uint8  newRank = 0 
)
inlineprivate

Definition at line 3250 of file Guild.cpp.

3251{
3252 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
3253 m_eventLog.AddEvent(trans, m_id, m_eventLog.GetNextGUID(), eventType, playerGuid1, playerGuid2, newRank);
3254 CharacterDatabase.CommitTransaction(trans);
3255
3256 sScriptMgr->OnGuildEvent(this, uint8(eventType), playerGuid1, playerGuid2, newRank);
3257}
LogHolder< EventLogEntry > m_eventLog
Definition: Guild.h:869
+ Here is the caller graph for this function:

◆ _MemberHasTabRights()

bool Guild::_MemberHasTabRights ( ObjectGuid  guid,
uint8  tabId,
int32  rights 
) const
inlineprivate

Definition at line 3237 of file Guild.cpp.

3238{
3239 if (Member const* member = GetMember(guid))
3240 {
3241 // Leader always has full rights
3242 if (member->IsRank(GuildRankId::GuildMaster) || m_leaderGuid == guid)
3243 return true;
3244 return (_GetRankBankTabRights(member->GetRankId(), tabId) & rights) == rights;
3245 }
3246 return false;
3247}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _ModifyBankMoney()

bool Guild::_ModifyBankMoney ( CharacterDatabaseTransaction  trans,
uint64  amount,
bool  add 
)
private

Definition at line 3112 of file Guild.cpp.

3113{
3114 if (add)
3115 m_bankMoney += amount;
3116 else
3117 {
3118 // Check if there is enough money in bank.
3119 if (m_bankMoney < amount)
3120 return false;
3121 m_bankMoney -= amount;
3122 }
3123
3125 stmt->setUInt64(0, m_bankMoney);
3126 stmt->setUInt64(1, m_id);
3127 trans->Append(stmt);
3128 return true;
3129}
@ CHAR_UPD_GUILD_BANK_MONEY
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _MoveItems()

void Guild::_MoveItems ( MoveItemData pSrc,
MoveItemData pDest,
uint32  splitedAmount 
) const
private

Definition at line 3294 of file Guild.cpp.

3295{
3296 // 1. Initialize source item
3297 if (!pSrc->InitItem())
3298 return; // No source item
3299
3300 // 2. Check source item
3301 if (!pSrc->CheckItem(splitedAmount))
3302 return; // Source item or splited amount is invalid
3303
3304 // 3. Check destination rights
3305 if (!pDest->HasStoreRights(pSrc))
3306 return; // Player has no rights to store item in destination
3307
3308 // 4. Check source withdraw rights
3309 if (!pSrc->HasWithdrawRights(pDest))
3310 return; // Player has no rights to withdraw items from source
3311
3312 // 5. Check split
3313 if (splitedAmount)
3314 {
3315 // 5.1. Clone source item
3316 if (!pSrc->CloneItem(splitedAmount))
3317 return; // Item could not be cloned
3318
3319 // 5.2. Move splited item to destination
3320 Guild::_DoItemsMove(pSrc, pDest, true, splitedAmount);
3321 }
3322 else // 6. No split
3323 {
3324 // 6.1. Try to merge items in destination (pDest->GetItem() == nullptr)
3325 InventoryResult mergeAttemptResult = Guild::_DoItemsMove(pSrc, pDest, false);
3326 if (mergeAttemptResult != EQUIP_ERR_OK) // Item could not be merged
3327 {
3328 // 6.2. Try to swap items
3329 // 6.2.1. Initialize destination item
3330 if (!pDest->InitItem())
3331 {
3332 pSrc->SendEquipError(mergeAttemptResult, pSrc->GetItem(false));
3333 return;
3334 }
3335
3336 // 6.2.2. Check rights to store item in source (opposite direction)
3337 if (!pSrc->HasStoreRights(pDest))
3338 return; // Player has no rights to store item in source (opposite direction)
3339
3340 if (!pDest->HasWithdrawRights(pSrc))
3341 return; // Player has no rights to withdraw item from destination (opposite direction)
3342
3343 // 6.2.3. Swap items (pDest->GetItem() != nullptr)
3344 Guild::_DoItemsMove(pSrc, pDest, true);
3345 }
3346 }
3347 // 7. Send changes
3348 _SendBankContentUpdate(pSrc, pDest);
3349}
static InventoryResult _DoItemsMove(MoveItemData *pSrc, MoveItemData *pDest, bool sendError, uint32 splitedAmount=0)
Definition: Guild.cpp:3351
void _SendBankContentUpdate(MoveItemData *pSrc, MoveItemData *pDest) const
Definition: Guild.cpp:3399
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _RemoveItem()

void Guild::_RemoveItem ( CharacterDatabaseTransaction  trans,
uint8  tabId,
uint8  slotId 
)
inlineprivate

Definition at line 3288 of file Guild.cpp.

3289{
3290 if (BankTab* pTab = GetBankTab(tabId))
3291 pTab->SetItem(trans, slotId, nullptr);
3292}
+ Here is the call graph for this function:

◆ _SendBankContentUpdate() [1/2]

void Guild::_SendBankContentUpdate ( MoveItemData pSrc,
MoveItemData pDest 
) const
private

Definition at line 3399 of file Guild.cpp.

3400{
3401 ASSERT(pSrc->IsBank() || pDest->IsBank());
3402
3403 uint8 tabId = 0;
3404 SlotIds slots;
3405 if (pSrc->IsBank()) // B ->
3406 {
3407 tabId = pSrc->GetContainer();
3408 slots.insert(pSrc->GetSlotId());
3409 if (pDest->IsBank()) // B -> B
3410 {
3411 // Same tab - add destination slots to collection
3412 if (pDest->GetContainer() == pSrc->GetContainer())
3413 pDest->CopySlots(slots);
3414 else // Different tabs - send second message
3415 {
3416 SlotIds destSlots;
3417 pDest->CopySlots(destSlots);
3418 _SendBankContentUpdate(pDest->GetContainer(), destSlots);
3419 }
3420 }
3421 }
3422 else if (pDest->IsBank()) // C -> B
3423 {
3424 tabId = pDest->GetContainer();
3425 pDest->CopySlots(slots);
3426 }
3427
3428 _SendBankContentUpdate(tabId, slots);
3429}
std::set< uint8 > SlotIds
Definition: Guild.h:303
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _SendBankContentUpdate() [2/2]

void Guild::_SendBankContentUpdate ( uint8  tabId,
SlotIds  slots 
) const
private

Definition at line 3431 of file Guild.cpp.

3432{
3433 if (BankTab const* tab = GetBankTab(tabId))
3434 {
3436 packet.FullUpdate = true; // @todo
3437 packet.Tab = int32(tabId);
3438 packet.Money = m_bankMoney;
3439
3440 for (SlotIds::const_iterator itr = slots.begin(); itr != slots.end(); ++itr)
3441 {
3442 Item const* tabItem = tab->GetItem(*itr);
3443
3445
3446 itemInfo.Slot = int32(*itr);
3447 itemInfo.Item.ItemID = int32(tabItem ? tabItem->GetEntry() : 0);
3448 itemInfo.Count = int32(tabItem ? tabItem->GetCount() : 0);
3449 itemInfo.EnchantmentID = int32(tabItem ? tabItem->GetEnchantmentId(PERM_ENCHANTMENT_SLOT) : 0);
3450 itemInfo.Charges = int32(tabItem ? abs(tabItem->GetSpellCharges()) : 0);
3451 itemInfo.OnUseEnchantmentID = int32(tabItem ? tabItem->GetEnchantmentId(USE_ENCHANTMENT_SLOT) : 0);
3452 itemInfo.Flags = 0;
3453 itemInfo.Locked = false;
3454
3455 if (tabItem)
3456 {
3457 uint8 i = 0;
3458 for (UF::SocketedGem const& gemData : tabItem->m_itemData->Gems)
3459 {
3460 if (gemData.ItemID)
3461 {
3463 gem.Slot = i;
3464 gem.Item.Initialize(&gemData);
3465 itemInfo.SocketEnchant.push_back(gem);
3466 }
3467 ++i;
3468 }
3469 }
3470
3471 packet.ItemInfo.push_back(itemInfo);
3472 }
3473
3474 for (auto const& [guid, member] : m_members)
3475 {
3476 if (!_MemberHasTabRights(member.GetGUID(), tabId, GUILD_BANK_RIGHT_VIEW_TAB))
3477 continue;
3478
3479 Player* player = member.FindPlayer();
3480 if (!player)
3481 continue;
3482
3483 packet.WithdrawalsRemaining = _GetMemberRemainingSlots(member, tabId);
3484 player->GetSession()->SendPacket(packet.Write());
3485 }
3486 }
3487}
@ PERM_ENCHANTMENT_SLOT
Definition: ItemDefines.h:179
@ USE_ENCHANTMENT_SLOT
Definition: ItemDefines.h:186
int32 _GetMemberRemainingSlots(Member const &member, uint8 tabId) const
Definition: Guild.cpp:3200
std::unordered_map< ObjectGuid, Member > m_members
Definition: Guild.h:865
bool _MemberHasTabRights(ObjectGuid guid, uint8 tabId, int32 rights) const
Definition: Guild.cpp:3237
uint32 GetEnchantmentId(EnchantmentSlot slot) const
Definition: Item.h:298
int32 GetSpellCharges(uint8 index=0) const
Definition: Item.h:314
UF::UpdateField< UF::ItemData, 0, TYPEID_ITEM > m_itemData
Definition: Item.h:449
uint32 GetEntry() const
Definition: Object.h:160
WorldSession * GetSession() const
Definition: Player.h:2089
WorldPacket const * Write() override
std::vector< GuildBankItemInfo > ItemInfo
Definition: GuildPackets.h:820
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
UpdateField< int32, 0, 1 > ItemID
Definition: UpdateFields.h:109
WorldPackets::Item::ItemInstance Item
Definition: GuildPackets.h:795
std::vector< Item::ItemGemData > SocketEnchant
Definition: GuildPackets.h:803
void Initialize(::Item const *item)
+ Here is the call graph for this function:

◆ _SetLeader()

void Guild::_SetLeader ( CharacterDatabaseTransaction  trans,
Member leader 
)
private

Definition at line 3131 of file Guild.cpp.

3132{
3133 bool isInTransaction = bool(trans);
3134 if (!isInTransaction)
3135 trans = CharacterDatabase.BeginTransaction();
3136
3137 m_leaderGuid = leader.GetGUID();
3138 leader.ChangeRank(trans, GuildRankId::GuildMaster);
3139
3141 stmt->setUInt64(0, m_leaderGuid.GetCounter());
3142 stmt->setUInt64(1, m_id);
3143 trans->Append(stmt);
3144
3145 if (!isInTransaction)
3146 CharacterDatabase.CommitTransaction(trans);
3147}
@ CHAR_UPD_GUILD_LEADER
LowType GetCounter() const
Definition: ObjectGuid.h:291
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _SetRankBankMoneyPerDay()

void Guild::_SetRankBankMoneyPerDay ( GuildRankId  rankId,
uint32  moneyPerDay 
)
private

Definition at line 3149 of file Guild.cpp.

3150{
3151 if (RankInfo* rankInfo = GetRankInfo(rankId))
3152 rankInfo->SetBankMoneyPerDay(moneyPerDay);
3153}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _SetRankBankTabRightsAndSlots()

void Guild::_SetRankBankTabRightsAndSlots ( GuildRankId  rankId,
GuildBankRightsAndSlots  rightsAndSlots,
bool  saveToDB = true 
)
private

Definition at line 3155 of file Guild.cpp.

3156{
3157 if (rightsAndSlots.GetTabId() >= _GetPurchasedTabsSize())
3158 return;
3159
3160 if (RankInfo* rankInfo = GetRankInfo(rankId))
3161 rankInfo->SetBankTabSlotsAndRights(rightsAndSlots, saveToDB);
3162}
int8 GetTabId() const
Definition: Guild.h:293
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _UpdateAccountsNumber()

void Guild::_UpdateAccountsNumber ( )
private

Definition at line 3082 of file Guild.cpp.

3083{
3084 // We use a set to be sure each element will be unique
3085 std::unordered_set<uint32> accountsIdSet;
3086 for (auto const& [guid, member] : m_members)
3087 accountsIdSet.insert(member.GetAccountId());
3088
3089 m_accountsNumber = accountsIdSet.size();
3090}
+ Here is the caller graph for this function:

◆ _UpdateMemberWithdrawSlots()

void Guild::_UpdateMemberWithdrawSlots ( CharacterDatabaseTransaction  trans,
ObjectGuid  guid,
uint8  tabId 
)
inlineprivate

Definition at line 3231 of file Guild.cpp.

3232{
3233 if (Member* member = GetMember(guid))
3234 member->UpdateBankTabWithdrawValue(trans, tabId, 1);
3235}
+ Here is the call graph for this function:

◆ AddGuildNews()

void Guild::AddGuildNews ( uint8  type,
ObjectGuid  guid,
uint32  flags,
uint32  value 
)

Definition at line 3597 of file Guild.cpp.

3598{
3599 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
3600 NewsLogEntry& news = m_newsLog.AddEvent(trans, m_id, m_newsLog.GetNextGUID(), GuildNews(type), guid, flags, value);
3601 CharacterDatabase.CommitTransaction(trans);
3602
3604 newsPacket.NewsEvents.reserve(1);
3605 news.WritePacket(newsPacket);
3606 BroadcastPacket(newsPacket.Write());
3607}
uint16 flags
Definition: DisableMgr.cpp:49
GuildNews
Definition: Guild.h:220
void BroadcastPacket(WorldPacket const *packet) const
Definition: Guild.cpp:2685
LogHolder< NewsLogEntry > m_newsLog
Definition: Guild.h:871
std::vector< GuildNewsEvent > NewsEvents
WorldPacket const * Write() override
+ Here is the call graph for this function:

◆ AddMember()

bool Guild::AddMember ( CharacterDatabaseTransaction  trans,
ObjectGuid  guid,
Optional< GuildRankId rankId = {} 
)

Definition at line 2732 of file Guild.cpp.

2733{
2735 // Player cannot be in guild
2736 if (player)
2737 {
2738 if (player->GetGuildId())
2739 return false;
2740 }
2741 else if (sCharacterCache->GetCharacterGuildIdByGuid(guid))
2742 return false;
2743
2744 // Remove all player signs from another petitions
2745 // This will be prevent attempt to join many guilds and corrupt guild data integrity
2747
2748 ObjectGuid::LowType lowguid = guid.GetCounter();
2749
2750 // If rank was not passed, assign lowest possible rank
2751 if (!rankId)
2752 rankId = _GetLowestRankId();
2753
2754 auto [memberIt, isNew] = m_members.try_emplace(guid, m_id, guid, *rankId);
2755 if (!isNew)
2756 {
2757 TC_LOG_ERROR("guild", "Tried to add {} to guild '{}'. Member already exists.", guid.ToString(), m_name);
2758 return false;
2759 }
2760
2761 Member& member = memberIt->second;
2762 std::string name;
2763 if (player)
2764 {
2765 player->SetInGuild(m_id);
2766 player->SetGuildIdInvited(UI64LIT(0));
2767 player->SetGuildRank(AsUnderlyingType(*rankId));
2768 player->SetGuildLevel(GetLevel());
2769 member.SetStats(player);
2770 SendLoginInfo(player->GetSession());
2771 name = player->GetName();
2772 }
2773 else
2774 {
2775 member.ResetFlags();
2776
2777 bool ok = false;
2778 // Player must exist
2780 stmt->setUInt64(0, lowguid);
2781 if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
2782 {
2783 Field* fields = result->Fetch();
2784 name = fields[0].GetString();
2785 member.SetStats(
2786 name,
2787 fields[1].GetUInt8(),
2788 fields[2].GetUInt8(),
2789 fields[3].GetUInt8(),
2790 fields[4].GetUInt8(),
2791 fields[5].GetUInt16(),
2792 fields[6].GetUInt32(),
2793 0);
2794
2795 ok = member.CheckStats();
2796 }
2797
2798 if (!ok)
2799 {
2800 m_members.erase(memberIt);
2801 return false;
2802 }
2803 sCharacterCache->UpdateCharacterGuildId(guid, GetId());
2804 }
2805
2806 member.SaveToDB(trans);
2807
2810
2811 WorldPackets::Guild::GuildEventPlayerJoined joinNotificationPacket;
2812 joinNotificationPacket.Guid = guid;
2813 joinNotificationPacket.Name = name;
2814 joinNotificationPacket.VirtualRealmAddress = GetVirtualRealmAddress();
2815 BroadcastPacket(joinNotificationPacket.Write());
2816
2817 // Call scripts if member was succesfully added (and stored to database)
2818 sScriptMgr->OnGuildAddMember(this, player, AsUnderlyingType(*rankId));
2819
2820 return true;
2821}
#define sCharacterCache
@ CHAR_SEL_CHAR_DATA_FOR_GUILD
std::shared_ptr< PreparedResultSet > PreparedQueryResult
@ GUILD_EVENT_LOG_JOIN_GUILD
Definition: Guild.h:193
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:165
constexpr std::underlying_type< E >::type AsUnderlyingType(E enumValue)
Definition: Util.h:475
Class used to access individual fields of database query result.
Definition: Field.h:90
std::string GetString() const
Definition: Field.cpp:118
GuildRankId _GetLowestRankId() const
Definition: Guild.h:882
ObjectGuid::LowType GetId() const
Definition: Guild.h:729
uint8 GetLevel() const
Definition: Guild.h:842
void SendLoginInfo(WorldSession *session)
Definition: Guild.cpp:2264
std::string m_name
Definition: Guild.h:854
void _UpdateAccountsNumber()
Definition: Guild.cpp:3082
void _LogEvent(GuildEventLogTypes eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2=UI64LIT(0), uint8 newRank=0)
Definition: Guild.cpp:3250
std::string ToString() const
Definition: ObjectGuid.cpp:554
uint64 LowType
Definition: ObjectGuid.h:276
void SetInGuild(ObjectGuid::LowType guildId)
Definition: Player.cpp:7377
ObjectGuid::LowType GetGuildId() const
Definition: Player.h:1982
void SetGuildRank(uint8 rankId)
Definition: Player.h:1977
void SetGuildLevel(uint32 level)
Definition: Player.h:1979
void SetGuildIdInvited(ObjectGuid::LowType GuildId)
Definition: Player.h:1981
static void RemovePetitionsAndSigns(ObjectGuid guid)
Definition: Player.cpp:22154
std::string const & GetName() const
Definition: Object.h:535
WorldPacket const * Write() override
uint32 GetVirtualRealmAddress()
Definition: World.cpp:3970
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BroadcastAddonToGuild()

void Guild::BroadcastAddonToGuild ( WorldSession session,
bool  officerOnly,
std::string_view  msg,
std::string_view  prefix,
bool  isLogged 
) const

Definition at line 2661 of file Guild.cpp.

2662{
2663 if (session && session->GetPlayer() && _HasRankRight(session->GetPlayer(), officerOnly ? GR_RIGHT_OFFCHATSPEAK : GR_RIGHT_GCHATSPEAK))
2664 {
2666 packet.Initialize(officerOnly ? CHAT_MSG_OFFICER : CHAT_MSG_GUILD, isLogged ? LANG_ADDON_LOGGED : LANG_ADDON, session->GetPlayer(), nullptr, msg, 0, "", DEFAULT_LOCALE, prefix);
2667 WorldPacket const* data = packet.Write();
2668 for (auto const& [guid, member] : m_members)
2669 if (Player* player = member.FindPlayer())
2670 if (player->GetSession() && _HasRankRight(player, officerOnly ? GR_RIGHT_OFFCHATLISTEN : GR_RIGHT_GCHATLISTEN) &&
2671 !player->GetSocial()->HasIgnore(session->GetPlayer()->GetGUID(), session->GetAccountGUID()) &&
2672 player->GetSession()->IsAddonRegistered(prefix))
2673 player->SendDirectMessage(data);
2674 }
2675}
#define DEFAULT_LOCALE
Definition: Common.h:66
@ GR_RIGHT_OFFCHATSPEAK
Definition: Guild.h:89
@ GR_RIGHT_OFFCHATLISTEN
Definition: Guild.h:88
@ LANG_ADDON_LOGGED
@ LANG_ADDON
@ CHAT_MSG_GUILD
@ CHAT_MSG_OFFICER
bool _HasRankRight(Player const *player, uint32 right) const
Definition: Guild.cpp:2990
void Initialize(ChatMsg chatType, Language language, WorldObject const *sender, WorldObject const *receiver, std::string_view message, uint32 achievementId=0, std::string_view channelName="", LocaleConstant locale=DEFAULT_LOCALE, std::string_view addonPrefix="")
WorldPacket const * Write() override
ObjectGuid GetAccountGUID() const
Definition: WorldSession.h:994
Player * GetPlayer() const
Definition: WorldSession.h:998
+ Here is the call graph for this function:

◆ BroadcastPacket()

void Guild::BroadcastPacket ( WorldPacket const *  packet) const

Definition at line 2685 of file Guild.cpp.

2686{
2687 for (auto const& [guid, member] : m_members)
2688 if (Player* player = member.FindConnectedPlayer())
2689 player->SendDirectMessage(packet);
2690}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BroadcastPacketIfTrackingAchievement()

void Guild::BroadcastPacketIfTrackingAchievement ( WorldPacket const *  packet,
uint32  criteriaId 
) const

Definition at line 2692 of file Guild.cpp.

2693{
2694 for (auto const& [guid, member] : m_members)
2695 if (member.IsTrackingCriteriaId(criteriaId))
2696 if (Player* player = member.FindPlayer())
2697 player->GetSession()->SendPacket(packet);
2698}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BroadcastPacketToRank()

void Guild::BroadcastPacketToRank ( WorldPacket const *  packet,
GuildRankId  rankId 
) const

Definition at line 2677 of file Guild.cpp.

2678{
2679 for (auto const& [guid, member] : m_members)
2680 if (member.IsRank(rankId))
2681 if (Player* player = member.FindConnectedPlayer())
2682 player->SendDirectMessage(packet);
2683}
+ Here is the call graph for this function:

◆ BroadcastToGuild()

void Guild::BroadcastToGuild ( WorldSession session,
bool  officerOnly,
std::string_view  msg,
uint32  language = LANG_UNIVERSAL 
) const

Definition at line 2646 of file Guild.cpp.

2647{
2648 if (session && session->GetPlayer() && _HasRankRight(session->GetPlayer(), officerOnly ? GR_RIGHT_OFFCHATSPEAK : GR_RIGHT_GCHATSPEAK))
2649 {
2651 packet.Initialize(officerOnly ? CHAT_MSG_OFFICER : CHAT_MSG_GUILD, Language(language), session->GetPlayer(), nullptr, msg);
2652 WorldPacket const* data = packet.Write();
2653 for (auto const& [guid, member] : m_members)
2654 if (Player* player = member.FindConnectedPlayer())
2655 if (player->GetSession() && _HasRankRight(player, officerOnly ? GR_RIGHT_OFFCHATLISTEN : GR_RIGHT_GCHATLISTEN) &&
2656 !player->GetSocial()->HasIgnore(session->GetPlayer()->GetGUID(), session->GetAccountGUID()))
2657 player->SendDirectMessage(data);
2658 }
2659}
Language
+ Here is the call graph for this function:

◆ BroadcastWorker()

template<class Do >
void Guild::BroadcastWorker ( Do &  _do,
Player except = nullptr 
)
inline

Definition at line 814 of file Guild.h.

815 {
816 for (auto itr = m_members.begin(); itr != m_members.end(); ++itr)
817 if (Player* player = itr->second.FindConnectedPlayer())
818 if (player != except)
819 _do(player);
820 }

◆ ChangeMemberRank()

bool Guild::ChangeMemberRank ( CharacterDatabaseTransaction  trans,
ObjectGuid  guid,
GuildRankId  newRank 
)

Definition at line 2880 of file Guild.cpp.

2881{
2882 if (GetRankInfo(newRank)) // Validate rank (allow only existing ranks)
2883 {
2884 if (Member* member = GetMember(guid))
2885 {
2886 member->ChangeRank(trans, newRank);
2887 return true;
2888 }
2889 }
2890
2891 return false;
2892}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Create()

bool Guild::Create ( Player pLeader,
std::string_view  name 
)

Definition at line 1131 of file Guild.cpp.

1132{
1133 // Check if guild with such name already exists
1134 if (sGuildMgr->GetGuildByName(name))
1135 return false;
1136
1137 WorldSession* pLeaderSession = pLeader->GetSession();
1138 if (!pLeaderSession)
1139 return false;
1140
1141 m_id = sGuildMgr->GenerateGuildId();
1142 m_leaderGuid = pLeader->GetGUID();
1143 m_name = name;
1144 m_info = "";
1145 m_motd = "No message set.";
1146 m_bankMoney = 0;
1148
1149 TC_LOG_DEBUG("guild", "GUILD: creating guild [{}] for leader {} {}",
1150 m_name, pLeader->GetName(), m_leaderGuid.ToString());
1151
1152 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
1153
1155 stmt->setUInt64(0, m_id);
1156 trans->Append(stmt);
1157
1158 uint8 index = 0;
1159 stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD);
1160 stmt->setUInt64( index, m_id);
1161 stmt->setString(++index, m_name);
1162 stmt->setUInt64(++index, m_leaderGuid.GetCounter());
1163 stmt->setString(++index, m_info);
1164 stmt->setString(++index, m_motd);
1165 stmt->setUInt64(++index, uint32(m_createdDate));
1166 stmt->setUInt32(++index, m_emblemInfo.GetStyle());
1167 stmt->setUInt32(++index, m_emblemInfo.GetColor());
1168 stmt->setUInt32(++index, m_emblemInfo.GetBorderStyle());
1169 stmt->setUInt32(++index, m_emblemInfo.GetBorderColor());
1170 stmt->setUInt32(++index, m_emblemInfo.GetBackgroundColor());
1171 stmt->setUInt64(++index, m_bankMoney);
1172 trans->Append(stmt);
1173
1174 _CreateDefaultGuildRanks(trans, pLeaderSession->GetSessionDbLocaleIndex()); // Create default ranks
1175 bool ret = AddMember(trans, m_leaderGuid, GuildRankId::GuildMaster); // Add guildmaster
1176
1177 CharacterDatabase.CommitTransaction(trans);
1178
1179 if (ret)
1180 {
1181 Member* leader = GetMember(m_leaderGuid);
1182 if (leader)
1183 SendEventNewLeader(leader, nullptr);
1184
1185 sScriptMgr->OnGuildCreate(this, pLeader, m_name);
1186 }
1187
1188 return ret;
1189}
@ CHAR_INS_GUILD
@ CHAR_DEL_GUILD_MEMBERS
uint32_t uint32
Definition: Define.h:143
#define sGuildMgr
Definition: GuildMgr.h:69
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:156
uint32 GetStyle() const
Definition: Guild.h:261
uint32 GetColor() const
Definition: Guild.h:262
uint32 GetBackgroundColor() const
Definition: Guild.h:265
uint32 GetBorderStyle() const
Definition: Guild.h:263
uint32 GetBorderColor() const
Definition: Guild.h:264
void SendEventNewLeader(Member *newLeader, Member *oldLeader, bool isSelfPromoted=false) const
Definition: Guild.cpp:2351
bool AddMember(CharacterDatabaseTransaction trans, ObjectGuid guid, Optional< GuildRankId > rankId={})
Definition: Guild.cpp:2732
std::string m_motd
Definition: Guild.h:856
EmblemInfo m_emblemInfo
Definition: Guild.h:860
void _CreateDefaultGuildRanks(CharacterDatabaseTransaction trans, LocaleConstant loc)
Definition: Guild.cpp:3030
std::string m_info
Definition: Guild.h:857
void setUInt32(const uint8 index, const uint32 value)
void setString(const uint8 index, const std::string &value)
Player session in the World.
Definition: WorldSession.h:956
LocaleConstant GetSessionDbLocaleIndex() const
time_t GetGameTime()
Definition: GameTime.cpp:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DeleteMember()

void Guild::DeleteMember ( CharacterDatabaseTransaction  trans,
ObjectGuid  guid,
bool  isDisbanding = false,
bool  isKicked = false,
bool  canDeleteGuild = false 
)

Definition at line 2823 of file Guild.cpp.

2824{
2825 // Guild master can be deleted when loading guild and guid doesn't exist in characters table
2826 // or when he is removed from guild by gm command
2827 if (m_leaderGuid == guid && !isDisbanding)
2828 {
2829 Member* oldLeader = nullptr;
2830 Member* newLeader = nullptr;
2831 for (auto& [memberGuid, member] : m_members)
2832 {
2833 if (memberGuid == guid)
2834 oldLeader = &member;
2835 else if (!newLeader || newLeader->GetRankId() > member.GetRankId())
2836 newLeader = &member;
2837 }
2838
2839 if (!newLeader)
2840 {
2841 Disband();
2842 if (canDeleteGuild)
2843 delete this;
2844 return;
2845 }
2846
2847 _SetLeader(trans, *newLeader);
2848
2849 // If leader does not exist (at guild loading with deleted leader) do not send broadcasts
2850 if (oldLeader)
2851 {
2852 SendEventNewLeader(newLeader, oldLeader, true);
2853 SendEventPlayerLeft(oldLeader);
2854 }
2855 }
2856 // Call script on remove before member is actually removed from guild (and database)
2857 sScriptMgr->OnGuildRemoveMember(this, guid, isDisbanding, isKicked);
2858
2859 m_members.erase(guid);
2860
2861 // If player not online data in data field will be loaded from guild tabs no need to update it !!
2863 if (player)
2864 {
2865 player->SetInGuild(UI64LIT(0));
2866 player->SetGuildRank(0);
2867 player->SetGuildLevel(0);
2868
2869 for (GuildPerkSpellsEntry const* entry : sGuildPerkSpellsStore)
2870 player->RemoveSpell(entry->SpellID, false, false);
2871 }
2872 else
2873 sCharacterCache->UpdateCharacterGuildId(guid, 0);
2874
2876 if (!isDisbanding)
2878}
DB2Storage< GuildPerkSpellsEntry > sGuildPerkSpellsStore("GuildPerkSpells.db2", &GuildPerkSpellsLoadInfo::Instance)
static void _DeleteMemberFromDB(CharacterDatabaseTransaction trans, ObjectGuid::LowType lowguid)
Definition: Guild.cpp:2998
void SendEventPlayerLeft(Member *leaver, Member *remover=nullptr, bool isRemoved=false) const
Definition: Guild.cpp:2372
void Disband()
Definition: Guild.cpp:1192
void _SetLeader(CharacterDatabaseTransaction trans, Member &leader)
Definition: Guild.cpp:3131
void RemoveSpell(uint32 spell_id, bool disabled=false, bool learn_low_rank=true, bool suppressMessaging=false)
Definition: Player.cpp:3281
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Disband()

void Guild::Disband ( )

Definition at line 1192 of file Guild.cpp.

1193{
1194 // Call scripts before guild data removed from database
1195 sScriptMgr->OnGuildDisband(this);
1196
1198 BroadcastPacket(packet.Write());
1199
1200 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
1201 // Remove all members
1202 while (!m_members.empty())
1203 {
1204 auto itr = m_members.begin();
1205 DeleteMember(trans, itr->second.GetGUID(), true);
1206 }
1207
1209 stmt->setUInt64(0, m_id);
1210 trans->Append(stmt);
1211
1212 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_RANKS);
1213 stmt->setUInt64(0, m_id);
1214 trans->Append(stmt);
1215
1216 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_TABS);
1217 stmt->setUInt64(0, m_id);
1218 trans->Append(stmt);
1219
1220 // Free bank tab used memory and delete items stored in them
1221 _DeleteBankItems(trans, true);
1222
1223 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_ITEMS);
1224 stmt->setUInt64(0, m_id);
1225 trans->Append(stmt);
1226
1227 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_RIGHTS);
1228 stmt->setUInt64(0, m_id);
1229 trans->Append(stmt);
1230
1231 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_EVENTLOGS);
1232 stmt->setUInt64(0, m_id);
1233 trans->Append(stmt);
1234
1235 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_EVENTLOGS);
1236 stmt->setUInt64(0, m_id);
1237 trans->Append(stmt);
1238
1239 CharacterDatabase.CommitTransaction(trans);
1240
1241 sGuildMgr->RemoveGuild(m_id);
1242}
@ CHAR_DEL_GUILD_BANK_TABS
@ CHAR_DEL_GUILD
@ CHAR_DEL_GUILD_BANK_EVENTLOGS
@ CHAR_DEL_GUILD_BANK_ITEMS
@ CHAR_DEL_GUILD_EVENTLOGS
void DeleteMember(CharacterDatabaseTransaction trans, ObjectGuid guid, bool isDisbanding=false, bool isKicked=false, bool canDeleteGuild=false)
Definition: Guild.cpp:2823
WorldPacket const * Write() override
Definition: GuildPackets.h:311
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetAchievementMgr() [1/2]

GuildAchievementMgr & Guild::GetAchievementMgr ( )
inline

Definition at line 838 of file Guild.h.

838{ return *m_achievementMgr; }
+ Here is the caller graph for this function:

◆ GetAchievementMgr() [2/2]

GuildAchievementMgr const & Guild::GetAchievementMgr ( ) const
inline

Definition at line 839 of file Guild.h.

839{ return *m_achievementMgr; }

◆ GetBankMoney()

uint64 Guild::GetBankMoney ( ) const
inline

Definition at line 736 of file Guild.h.

736{ return m_bankMoney; }
+ Here is the caller graph for this function:

◆ GetBankTab() [1/2]

BankTab * Guild::GetBankTab ( uint8  tabId)
inlineprivate

Definition at line 885 of file Guild.h.

885{ return tabId < m_bankTabs.size() ? &m_bankTabs[tabId] : nullptr; }
+ Here is the caller graph for this function:

◆ GetBankTab() [2/2]

BankTab const * Guild::GetBankTab ( uint8  tabId) const
inlineprivate

Definition at line 886 of file Guild.h.

886{ return tabId < m_bankTabs.size() ? &m_bankTabs[tabId] : nullptr; }

◆ GetCreatedDate()

time_t Guild::GetCreatedDate ( ) const
inline

Definition at line 735 of file Guild.h.

735{ return m_createdDate; }
+ Here is the caller graph for this function:

◆ GetEmblemInfo()

EmblemInfo const & Guild::GetEmblemInfo ( ) const
inline

Definition at line 846 of file Guild.h.

846{ return m_emblemInfo; }

◆ GetGUID()

ObjectGuid Guild::GetGUID ( ) const
inline

Definition at line 730 of file Guild.h.

730{ return ObjectGuid::Create<HighGuid::Guild>(m_id); }
+ Here is the caller graph for this function:

◆ GetId()

ObjectGuid::LowType Guild::GetId ( ) const
inline

Definition at line 729 of file Guild.h.

729{ return m_id; }
+ Here is the caller graph for this function:

◆ GetInfo()

std::string const & Guild::GetInfo ( ) const
inline

Definition at line 734 of file Guild.h.

734{ return m_info; }
+ Here is the caller graph for this function:

◆ GetLeaderGUID()

ObjectGuid Guild::GetLeaderGUID ( ) const
inline

Definition at line 731 of file Guild.h.

731{ return m_leaderGuid; }
+ Here is the caller graph for this function:

◆ GetLevel()

uint8 Guild::GetLevel ( ) const
inline

Definition at line 842 of file Guild.h.

842{ return GUILD_OLD_MAX_LEVEL; }
@ GUILD_OLD_MAX_LEVEL
Definition: Guild.h:64
+ Here is the caller graph for this function:

◆ GetMember() [1/3]

Member * Guild::GetMember ( ObjectGuid const &  guid)
inlineprivate

Definition at line 894 of file Guild.h.

895 {
896 auto itr = m_members.find(guid);
897 return (itr != m_members.end()) ? &itr->second : nullptr;
898 }

◆ GetMember() [2/3]

Member const * Guild::GetMember ( ObjectGuid const &  guid) const
inlineprivate

Definition at line 888 of file Guild.h.

889 {
890 auto itr = m_members.find(guid);
891 return (itr != m_members.end()) ? &itr->second : nullptr;
892 }
+ Here is the caller graph for this function:

◆ GetMember() [3/3]

Member * Guild::GetMember ( std::string_view  name)
inlineprivate

Definition at line 900 of file Guild.h.

901 {
902 for (auto itr = m_members.begin(); itr != m_members.end(); ++itr)
903 if (itr->second.GetName() == name)
904 return &itr->second;
905
906 return nullptr;
907 }

◆ GetMemberAvailableMoneyForRepairItems()

uint64 Guild::GetMemberAvailableMoneyForRepairItems ( ObjectGuid  guid) const

Definition at line 2899 of file Guild.cpp.

2900{
2901 Member const* member = GetMember(guid);
2902 if (!member)
2903 return 0;
2904
2905 return std::min(m_bankMoney, static_cast<uint64>(_GetMemberRemainingMoney(*member)));
2906}
uint64_t uint64
Definition: Define.h:142
int64 _GetMemberRemainingMoney(Member const &member) const
Definition: Guild.cpp:3216
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetMembersCount()

uint32 Guild::GetMembersCount ( ) const
inline

Definition at line 828 of file Guild.h.

828{ return uint32(m_members.size()); }
+ Here is the caller graph for this function:

◆ GetMOTD()

std::string const & Guild::GetMOTD ( ) const
inline

Definition at line 733 of file Guild.h.

733{ return m_motd; }
+ Here is the caller graph for this function:

◆ GetName()

std::string const & Guild::GetName ( ) const
inline

Definition at line 732 of file Guild.h.

732{ return m_name; }
+ Here is the caller graph for this function:

◆ GetRankInfo() [1/4]

Guild::RankInfo * Guild::GetRankInfo ( GuildRankId  rankId)
private

Definition at line 2960 of file Guild.cpp.

2961{
2962 auto rankItr = std::find_if(m_ranks.begin(), m_ranks.end(), [rankId](RankInfo const& rank)
2963 {
2964 return rank.GetId() == rankId;
2965 });
2966
2967 return rankItr != m_ranks.end() ? &*rankItr : nullptr;
2968}

◆ GetRankInfo() [2/4]

Guild::Guild::RankInfo const * Guild::GetRankInfo ( GuildRankId  rankId) const
private

Definition at line 2950 of file Guild.cpp.

2951{
2952 auto rankItr = std::find_if(m_ranks.begin(), m_ranks.end(), [rankId](RankInfo const& rank)
2953 {
2954 return rank.GetId() == rankId;
2955 });
2956
2957 return rankItr != m_ranks.end() ? &*rankItr : nullptr;
2958}
+ Here is the caller graph for this function:

◆ GetRankInfo() [3/4]

Guild::Guild::RankInfo * Guild::GetRankInfo ( GuildRankOrder  rankOrder)
private

Definition at line 2980 of file Guild.cpp.

2981{
2982 auto rankItr = std::find_if(m_ranks.begin(), m_ranks.end(), [rankOrder](RankInfo const& rank)
2983 {
2984 return rank.GetOrder() == rankOrder;
2985 });
2986
2987 return rankItr != m_ranks.end() ? &*rankItr : nullptr;
2988}

◆ GetRankInfo() [4/4]

Guild::Guild::RankInfo const * Guild::GetRankInfo ( GuildRankOrder  rankOrder) const
private

Definition at line 2970 of file Guild.cpp.

2971{
2972 auto rankItr = std::find_if(m_ranks.begin(), m_ranks.end(), [rankOrder](RankInfo const& rank)
2973 {
2974 return rank.GetOrder() == rankOrder;
2975 });
2976
2977 return rankItr != m_ranks.end() ? &*rankItr : nullptr;
2978}

◆ HandleAcceptMember()

void Guild::HandleAcceptMember ( WorldSession session)

Definition at line 1724 of file Guild.cpp.

1725{
1726 Player* player = session->GetPlayer();
1727 if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) &&
1728 player->GetTeam() != sCharacterCache->GetCharacterTeamByGuid(GetLeaderGUID()))
1729 return;
1730
1731 CharacterDatabaseTransaction trans(nullptr);
1732 AddMember(trans, player->GetGUID());
1733}
ObjectGuid GetLeaderGUID() const
Definition: Guild.h:731
uint32 GetTeam() const
Definition: Player.h:2225
#define sWorld
Definition: World.h:962
@ CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD
Definition: World.h:111
+ Here is the call graph for this function:

◆ HandleAddNewRank()

void Guild::HandleAddNewRank ( WorldSession session,
std::string_view  name 
)

Definition at line 1906 of file Guild.cpp.

1907{
1909 if (size >= GUILD_RANKS_MAX_COUNT)
1910 return;
1911
1912 // Only leader can add new rank
1913 if (_IsLeader(session->GetPlayer()))
1914 {
1915 CharacterDatabaseTransaction trans(nullptr);
1917 {
1919 BroadcastPacket(eventPacket.Write());
1920 }
1921 }
1922}
bool _IsLeader(Player *player) const
Definition: Guild.cpp:3095
uint8 _GetRanksSize() const
Definition: Guild.h:875
WorldPacket const * Write() override
Definition: GuildPackets.h:293
constexpr std::size_t size()
Definition: UpdateField.h:786
+ Here is the call graph for this function:

◆ HandleBuyBankTab()

void Guild::HandleBuyBankTab ( WorldSession session,
uint8  tabId 
)

Hack to force client to update permissions

Definition at line 1611 of file Guild.cpp.

1612{
1613 Player* player = session->GetPlayer();
1614 if (!player)
1615 return;
1616
1617 Member const* member = GetMember(player->GetGUID());
1618 if (!member)
1619 return;
1620
1622 return;
1623
1624 if (tabId != _GetPurchasedTabsSize())
1625 return;
1626
1627 if (tabId >= GUILD_BANK_MAX_TABS)
1628 return;
1629
1630 // Do not get money for bank tabs that the GM bought, we had to buy them already.
1631 // This is just a speedup check, GetGuildBankTabPrice will return 0.
1632 if (tabId < GUILD_BANK_MAX_TABS - 2) // 7th tab is actually the 6th
1633 {
1634 int64 tabCost = GetGuildBankTabPrice(tabId) * GOLD;
1635 if (!player->HasEnoughMoney(tabCost)) // Should not happen, this is checked by client
1636 return;
1637
1638 player->ModifyMoney(-tabCost);
1639 }
1640
1642
1644 BroadcastPacket(packet.Write());
1645
1646 SendPermissions(session);
1647}
uint64 GetGuildBankTabPrice(uint8 tabId)
Definition: Guild.cpp:48
@ GOLD
void SendPermissions(WorldSession *session) const
Definition: Guild.cpp:2223
void _CreateNewBankTab()
Definition: Guild.cpp:3006
bool ModifyMoney(int64 amount, bool sendError=true)
Definition: Player.cpp:23738
bool HasEnoughMoney(uint64 amount) const
Definition: Player.h:1729
WorldPacket const * Write() override
Definition: GuildPackets.h:378
+ Here is the call graph for this function:

◆ HandleDelete()

void Guild::HandleDelete ( WorldSession session)

Definition at line 2115 of file Guild.cpp.

2116{
2117 // Only leader can disband guild
2118 if (_IsLeader(session->GetPlayer()))
2119 {
2120 Disband();
2121 TC_LOG_DEBUG("guild", "{} successfully deleted", GetGUID().ToString());
2122 delete this;
2123 }
2124}
ObjectGuid GetGUID() const
Definition: Guild.h:730
string ToString(int i)
Definition: strutil.h:491
+ Here is the call graph for this function:

◆ HandleGetAchievementMembers()

void Guild::HandleGetAchievementMembers ( WorldSession session,
uint32  achievementId 
) const

Definition at line 1438 of file Guild.cpp.

1439{
1440 GetAchievementMgr().SendAchievementMembers(session->GetPlayer(), achievementId);
1441}
void SendAchievementMembers(Player *receiver, uint32 achievementId) const
GuildAchievementMgr & GetAchievementMgr()
Definition: Guild.h:838
+ Here is the call graph for this function:

◆ HandleGuildPartyRequest()

void Guild::HandleGuildPartyRequest ( WorldSession session) const

Definition at line 2126 of file Guild.cpp.

2127{
2128 Player* player = session->GetPlayer();
2129 Group* group = player->GetGroup();
2130
2131 // Make sure player is a member of the guild and that he is in a group.
2132 if (!IsMember(player->GetGUID()) || !group)
2133 return;
2134
2135 WorldPackets::Guild::GuildPartyState partyStateResponse;
2136 partyStateResponse.InGuildParty = (player->GetMap()->GetOwnerGuildId(player->GetTeam()) == GetId());
2137 partyStateResponse.NumMembers = 0;
2138 partyStateResponse.NumRequired = 0;
2139 partyStateResponse.GuildXPEarnedMult = 0.0f;
2140 session->SendPacket(partyStateResponse.Write());
2141
2142 TC_LOG_DEBUG("guild", "SMSG_GUILD_PARTY_STATE_RESPONSE [{}]", session->GetPlayerInfo());
2143}
Definition: Group.h:189
bool IsMember(ObjectGuid guid) const
Definition: Guild.cpp:2894
virtual ObjectGuid::LowType GetOwnerGuildId(uint32=TEAM_OTHER) const
Definition: Map.h:448
Group * GetGroup(Optional< uint8 > partyIndex)
Definition: Player.h:2593
Map * GetMap() const
Definition: Object.h:603
WorldPacket const * Write() override
std::string GetPlayerInfo() const
+ Here is the call graph for this function:

◆ HandleGuildRequestChallengeUpdate()

void Guild::HandleGuildRequestChallengeUpdate ( WorldSession session) const
Todo:
current count

Definition at line 2145 of file Guild.cpp.

2146{
2148
2149 for (int i = 0; i < GUILD_CHALLENGES_TYPES; ++i)
2150 updatePacket.CurrentCount[i] = int32(0);
2151
2152 for (int i = 0; i < GUILD_CHALLENGES_TYPES; ++i)
2153 updatePacket.MaxCount[i] = int32(GuildChallengesMaxCount[i]);
2154
2155 for (int i = 0; i < GUILD_CHALLENGES_TYPES; ++i)
2157
2158 for (int i = 0; i < GUILD_CHALLENGES_TYPES; ++i)
2159 updatePacket.Gold[i] = int32(GuildChallengeGoldReward[i]);
2160
2161 session->SendPacket(updatePacket.Write());
2162}
#define GUILD_CHALLENGES_TYPES
Definition: Guild.h:244
const uint32 GuildChallengeMaxLevelGoldReward[GUILD_CHALLENGES_TYPES]
Definition: Guild.h:247
const uint32 GuildChallengeGoldReward[GUILD_CHALLENGES_TYPES]
Definition: Guild.h:246
const uint32 GuildChallengesMaxCount[GUILD_CHALLENGES_TYPES]
Definition: Guild.h:248
int32 CurrentCount[GUILD_CHALLENGES_TYPES]
int32 MaxLevelGold[GUILD_CHALLENGES_TYPES]
int32 Gold[GUILD_CHALLENGES_TYPES]
WorldPacket const * Write() override
int32 MaxCount[GUILD_CHALLENGES_TYPES]
+ Here is the call graph for this function:

◆ HandleInviteMember()

void Guild::HandleInviteMember ( WorldSession session,
std::string_view  name 
)

Definition at line 1649 of file Guild.cpp.

1650{
1651 Player* pInvitee = ObjectAccessor::FindPlayerByName(name);
1652 if (!pInvitee)
1653 {
1655 return;
1656 }
1657
1658 Player* player = session->GetPlayer();
1659 // Do not show invitations from ignored players
1660 if (pInvitee->GetSocial()->HasIgnore(player->GetGUID(), player->GetSession()->GetAccountGUID()))
1661 return;
1662
1663 if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && pInvitee->GetTeam() != player->GetTeam())
1664 {
1666 return;
1667 }
1668
1669 // Invited player cannot be in another guild
1670 if (pInvitee->GetGuildId())
1671 {
1673 return;
1674 }
1675
1676 // Invited player cannot be invited
1677 if (pInvitee->GetGuildIdInvited())
1678 {
1680 return;
1681 }
1682
1683 // Inviting player must have rights to invite
1684 if (!_HasRankRight(player, GR_RIGHT_INVITE))
1685 {
1687 return;
1688 }
1689
1691
1692 TC_LOG_DEBUG("guild", "Player {} invited {} to join his Guild", player->GetName(), pInvitee->GetName());
1693
1694 pInvitee->SetGuildIdInvited(m_id);
1696
1698
1701 invite.GuildGUID = GetGUID();
1702
1709
1710 invite.InviterName = player->GetName();
1711 invite.GuildName = GetName();
1712
1713 if (Guild* oldGuild = pInvitee->GetGuild())
1714 {
1715 invite.OldGuildGUID = oldGuild->GetGUID();
1716 invite.OldGuildName = oldGuild->GetName();
1718 }
1719
1720 pInvitee->SendDirectMessage(invite.Write());
1721 TC_LOG_DEBUG("guild", "SMSG_GUILD_INVITE [{}]", pInvitee->GetName());
1722}
@ GUILD_COMMAND_INVITE_PLAYER
Definition: Guild.h:113
@ ERR_GUILD_PERMISSIONS
Definition: Guild.h:141
@ ERR_ALREADY_IN_GUILD_S
Definition: Guild.h:135
@ ERR_GUILD_COMMAND_SUCCESS
Definition: Guild.h:132
@ ERR_GUILD_NOT_ALLIED
Definition: Guild.h:145
@ ERR_GUILD_PLAYER_NOT_FOUND_S
Definition: Guild.h:144
@ ERR_ALREADY_INVITED_TO_GUILD_S
Definition: Guild.h:137
@ GR_RIGHT_INVITE
Definition: Guild.h:90
@ GUILD_EVENT_LOG_INVITE_PLAYER
Definition: Guild.h:192
uint32 GetAchievementPoints() const
Definition: Guild.h:306
static void SendCommandResult(WorldSession *session, GuildCommandType type, GuildCommandError errCode, std::string_view param="")
Definition: Guild.cpp:57
std::string const & GetName() const
Definition: Guild.h:732
bool HasIgnore(ObjectGuid const &ignoreGuid, ObjectGuid const &ignoreAccountGuid)
Definition: SocialMgr.cpp:189
PlayerSocial * GetSocial() const
Definition: Player.h:1158
void SendDirectMessage(WorldPacket const *data) const
Definition: Player.cpp:6307
Guild * GetGuild()
Definition: Player.cpp:28948
ObjectGuid::LowType GetGuildIdInvited() const
Definition: Player.h:1985
WorldPacket const * Write() override
TC_GAME_API Player * FindPlayerByName(std::string_view name)
+ Here is the call graph for this function:

◆ HandleLeaveMember()

void Guild::HandleLeaveMember ( WorldSession session)

Definition at line 1735 of file Guild.cpp.

1736{
1737 Player* player = session->GetPlayer();
1738 bool disband = false;
1739
1740 // If leader is leaving
1741 if (_IsLeader(player))
1742 {
1743 if (m_members.size() > 1)
1744 // Leader cannot leave if he is not the last member
1746 else
1747 {
1748 // Guild is disbanded if leader leaves.
1749 Disband();
1750 disband = true;
1751 }
1752 }
1753 else
1754 {
1757
1758 CharacterDatabaseTransaction trans(nullptr);
1759 DeleteMember(trans, player->GetGUID(), false, false);
1760
1762 }
1763
1764 sCalendarMgr->RemovePlayerGuildEventsAndSignups(player->GetGUID(), GetId());
1765
1766 if (disband)
1767 delete this;
1768}
#define sCalendarMgr
Definition: CalendarMgr.h:350
@ GUILD_COMMAND_LEAVE_GUILD
Definition: Guild.h:114
@ ERR_GUILD_LEADER_LEAVE
Definition: Guild.h:140
@ GUILD_EVENT_LOG_LEAVE_GUILD
Definition: Guild.h:197
+ Here is the call graph for this function:

◆ HandleMemberDepositMoney()

void Guild::HandleMemberDepositMoney ( WorldSession session,
uint64  amount,
bool  cashFlow = false 
)

Definition at line 2015 of file Guild.cpp.

2016{
2017 // guild bank cannot have more than MAX_MONEY_AMOUNT
2018 amount = std::min(amount, MAX_MONEY_AMOUNT - m_bankMoney);
2019 if (!amount)
2020 return;
2021
2022 Player* player = session->GetPlayer();
2023
2024 // Call script after validation and before money transfer.
2025 sScriptMgr->OnGuildMemberDepositMoney(this, player, amount);
2026
2027 if (m_bankMoney > GUILD_BANK_MONEY_LIMIT - amount)
2028 {
2029 if (!cashFlow)
2031 return;
2032 }
2033
2034 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
2035 _ModifyBankMoney(trans, amount, true);
2036 if (!cashFlow)
2037 {
2038 player->ModifyMoney(-int64(amount));
2039 player->SaveGoldToDB(trans);
2040 }
2041
2043 CharacterDatabase.CommitTransaction(trans);
2044
2046
2048 {
2049 sLog->OutCommand(player->GetSession()->GetAccountId(),
2050 "GM {} (Account: {}) deposit money (Amount: {}) to guild bank (Guild ID {})",
2051 player->GetName(), player->GetSession()->GetAccountId(), amount, m_id);
2052 }
2053}
constexpr uint64 GUILD_BANK_MONEY_LIMIT
Definition: Guild.h:67
@ GUILD_COMMAND_MOVE_ITEM
Definition: Guild.h:126
@ ERR_GUILD_TOO_MUCH_MONEY
Definition: Guild.h:156
@ GUILD_BANK_LOG_DEPOSIT_MONEY
Definition: Guild.h:181
@ GUILD_BANK_LOG_CASH_FLOW_DEPOSIT
Definition: Guild.h:187
#define sLog
Definition: Log.h:130
uint64 const MAX_MONEY_AMOUNT
Definition: Player.cpp:151
void _LogBankEvent(CharacterDatabaseTransaction trans, GuildBankEventLogTypes eventType, uint8 tabId, ObjectGuid::LowType playerGuid, uint64 itemOrMoney, uint16 itemStackCount=0, uint8 destTabId=0)
Definition: Guild.cpp:3260
bool _ModifyBankMoney(CharacterDatabaseTransaction trans, uint64 amount, bool add)
Definition: Guild.cpp:3112
void SendEventBankMoneyChanged() const
Definition: Guild.cpp:2330
void SaveGoldToDB(CharacterDatabaseTransaction trans) const
Definition: Player.cpp:20059
bool HasPermission(uint32 permissionId)
uint32 GetAccountId() const
Definition: WorldSession.h:993
@ RBAC_PERM_LOG_GM_TRADE
Definition: RBAC.h:64
+ Here is the call graph for this function:

◆ HandleMemberLogout()

void Guild::HandleMemberLogout ( WorldSession session)

Definition at line 2101 of file Guild.cpp.

2102{
2103 Player* player = session->GetPlayer();
2104 if (Member* member = GetMember(player->GetGUID()))
2105 {
2106 member->SetStats(player);
2107 member->UpdateLogoutTime();
2108 member->ResetFlags();
2109 }
2110
2111 SendEventPresenceChanged(session, false, true);
2112 SaveToDB();
2113}
void SaveToDB()
Definition: Guild.cpp:1244
void SendEventPresenceChanged(WorldSession *session, bool loggedOn, bool broadcast=false) const
Definition: Guild.cpp:2390
+ Here is the call graph for this function:

◆ HandleMemberWithdrawMoney()

bool Guild::HandleMemberWithdrawMoney ( WorldSession session,
uint64  amount,
bool  repair = false 
)

Definition at line 2055 of file Guild.cpp.

2056{
2057 // clamp amount to MAX_MONEY_AMOUNT, Players can't hold more than that anyway
2058 amount = std::min(amount, MAX_MONEY_AMOUNT);
2059
2060 if (m_bankMoney < amount) // Not enough money in bank
2061 return false;
2062
2063 Player* player = session->GetPlayer();
2064
2065 Member* member = GetMember(player->GetGUID());
2066 if (!member)
2067 return false;
2068
2070 return false;
2071
2072 if (_GetMemberRemainingMoney(*member) < int64(amount)) // Check if we have enough slot/money today
2073 return false;
2074
2075 // Call script after validation and before money transfer.
2076 sScriptMgr->OnGuildMemberWitdrawMoney(this, player, amount, repair);
2077
2078 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
2079 // Add money to player (if required)
2080 if (!repair)
2081 {
2082 if (!player->ModifyMoney(amount))
2083 return false;
2084
2085 player->SaveGoldToDB(trans);
2086 }
2087
2088 // Update remaining money amount
2089 member->UpdateBankMoneyWithdrawValue(trans, amount);
2090 // Remove money from bank
2091 _ModifyBankMoney(trans, amount, false);
2092
2093 // Log guild bank event
2095 CharacterDatabase.CommitTransaction(trans);
2096
2098 return true;
2099}
@ GUILD_BANK_LOG_WITHDRAW_MONEY
Definition: Guild.h:182
@ GUILD_BANK_LOG_REPAIR_MONEY
Definition: Guild.h:183
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandleNewsSetSticky()

void Guild::HandleNewsSetSticky ( WorldSession session,
uint32  newsId,
bool  sticky 
)

Definition at line 3619 of file Guild.cpp.

3620{
3621 std::list<NewsLogEntry>& newsLog = m_newsLog.GetGuildLog();
3622 auto itr = newsLog.begin();
3623 while (itr != newsLog.end() && itr->GetGUID() != newsId)
3624 ++itr;
3625
3626 if (itr == newsLog.end())
3627 {
3628 TC_LOG_DEBUG("guild", "HandleNewsSetSticky: [{}] requested unknown newsId {} - Sticky: {}",
3629 session->GetPlayerInfo(), newsId, sticky);
3630 return;
3631 }
3632
3633 itr->SetSticky(sticky);
3634
3635 TC_LOG_DEBUG("guild", "HandleNewsSetSticky: [{}] changed newsId {} sticky to {}",
3636 session->GetPlayerInfo(), newsId, sticky);
3637
3639 newsPacket.NewsEvents.reserve(1);
3640 itr->WritePacket(newsPacket);
3641 session->SendPacket(newsPacket.Write());
3642}
+ Here is the call graph for this function:

◆ HandleRemoveMember()

void Guild::HandleRemoveMember ( WorldSession session,
ObjectGuid  guid 
)

Definition at line 1770 of file Guild.cpp.

1771{
1772 Player* player = session->GetPlayer();
1773
1774 // Player must have rights to remove members
1775 if (!_HasRankRight(player, GR_RIGHT_REMOVE))
1777 else if (Member* member = GetMember(guid))
1778 {
1779 std::string name = member->GetName();
1780
1781 // Guild masters cannot be removed
1782 if (member->IsRank(GuildRankId::GuildMaster))
1784 // Do not allow to remove player with the same rank or higher
1785 else
1786 {
1787 Member* memberMe = GetMember(player->GetGUID());
1788 RankInfo const* myRank = GetRankInfo(memberMe->GetRankId());
1789 RankInfo const* targetRank = GetRankInfo(member->GetRankId());
1790
1791 if (!memberMe || targetRank->GetOrder() <= myRank->GetOrder())
1793 else
1794 {
1796 SendEventPlayerLeft(member, memberMe, true);
1797
1798 // After call to DeleteMember pointer to member becomes invalid
1799 CharacterDatabaseTransaction trans(nullptr);
1800 DeleteMember(trans, guid, false, true);
1801
1803 }
1804 }
1805 }
1806}
@ GUILD_COMMAND_REMOVE_PLAYER
Definition: Guild.h:118
@ ERR_GUILD_RANK_TOO_HIGH_S
Definition: Guild.h:146
@ GR_RIGHT_REMOVE
Definition: Guild.h:91
@ GUILD_EVENT_LOG_UNINVITE_PLAYER
Definition: Guild.h:196
+ Here is the call graph for this function:

◆ HandleRemoveRank()

void Guild::HandleRemoveRank ( WorldSession session,
GuildRankOrder  rankOrder 
)

Definition at line 1924 of file Guild.cpp.

1925{
1926 // Cannot remove rank if total count is minimum allowed by the client or is not leader
1927 if (_GetRanksSize() <= GUILD_RANKS_MIN_COUNT || !_IsLeader(session->GetPlayer()))
1928 return;
1929
1930 auto rankItr = std::find_if(m_ranks.begin(), m_ranks.end(), [rankOrder](RankInfo const& rank)
1931 {
1932 return rank.GetOrder() == rankOrder;
1933 });
1934
1935 if (rankItr == m_ranks.end())
1936 return;
1937
1938 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
1939
1940 // Delete bank rights for rank
1942 stmt->setUInt64(0, m_id);
1943 stmt->setUInt8(1, AsUnderlyingType(rankItr->GetId()));
1944 trans->Append(stmt);
1945
1946 // Delete rank
1947 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_RANK);
1948 stmt->setUInt64(0, m_id);
1949 stmt->setUInt8(1, AsUnderlyingType(rankItr->GetId()));
1950 trans->Append(stmt);
1951
1952 m_ranks.erase(rankItr);
1953
1954 // correct order of other ranks
1955 for (RankInfo& otherRank : m_ranks)
1956 {
1957 if (otherRank.GetOrder() < rankOrder)
1958 continue;
1959
1960 otherRank.SetOrder(GuildRankOrder(AsUnderlyingType(otherRank.GetOrder()) - 1));
1961
1962 stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_RANK_ORDER);
1963 stmt->setUInt8(0, AsUnderlyingType(otherRank.GetOrder()));
1964 stmt->setUInt8(1, AsUnderlyingType(otherRank.GetId()));
1965 stmt->setUInt64(2, m_id);
1966 trans->Append(stmt);
1967 }
1968
1969 CharacterDatabase.CommitTransaction(trans);
1970
1972 BroadcastPacket(eventPacket.Write());
1973}
@ CHAR_DEL_GUILD_BANK_RIGHTS_FOR_RANK
@ CHAR_UPD_GUILD_RANK_ORDER
@ CHAR_DEL_GUILD_RANK
@ GUILD_RANKS_MIN_COUNT
Definition: Guild.h:57
+ Here is the call graph for this function:

◆ HandleRoster()

void Guild::HandleRoster ( WorldSession session)

Definition at line 1305 of file Guild.cpp.

1306{
1308
1311 roster.GuildFlags = 0;
1312
1313 roster.MemberData.reserve(m_members.size());
1314
1315 bool sendOfficerNote = _HasRankRight(session->GetPlayer(), GR_RIGHT_VIEWOFFNOTE);
1316 for (auto const& [guid, member] : m_members)
1317 {
1318 WorldPackets::Guild::GuildRosterMemberData& memberData = roster.MemberData.emplace_back();
1319
1320 memberData.Guid = member.GetGUID();
1321 memberData.RankID = int32(member.GetRankId());
1322 memberData.AreaID = int32(member.GetZoneId());
1323 memberData.PersonalAchievementPoints = int32(member.GetAchievementPoints());
1324 memberData.GuildReputation = int32(member.GetTotalReputation());
1325 memberData.LastSave = member.GetInactiveDays();
1326
1327 //GuildRosterProfessionData
1328
1330 memberData.Status = member.GetFlags();
1331 memberData.Level = member.GetLevel();
1332 memberData.ClassID = member.GetClass();
1333 memberData.Gender = member.GetGender();
1334 memberData.RaceID = member.GetRace();
1335
1336 memberData.Authenticated = false;
1337 memberData.SorEligible = false;
1338
1339 memberData.Name = member.GetName();
1340 memberData.Note = member.GetPublicNote();
1341 if (sendOfficerNote)
1342 memberData.OfficerNote = member.GetOfficerNote();
1343
1344 }
1345
1346 roster.WelcomeText = m_motd;
1347 roster.InfoText = m_info;
1348
1349 TC_LOG_DEBUG("guild", "SMSG_GUILD_ROSTER [{}]", session->GetPlayerInfo());
1350 session->SendPacket(roster.Write());
1351}
@ GR_RIGHT_VIEWOFFNOTE
Definition: Guild.h:100
WorldPacket const * Write() override
std::vector< GuildRosterMemberData > MemberData
Definition: GuildPackets.h:130
+ Here is the call graph for this function:

◆ HandleSetAchievementTracking()

void Guild::HandleSetAchievementTracking ( WorldSession session,
uint32 const *  achievementIdsBegin,
uint32 const *  achievementIdsEnd 
)

Definition at line 1406 of file Guild.cpp.

1407{
1408 Player* player = session->GetPlayer();
1409
1410 if (Member* member = GetMember(player->GetGUID()))
1411 {
1412 std::set<uint32> criteriaIds;
1413
1414 for (uint32 const* achievementIdItr = achievementIdsBegin; achievementIdItr != achievementIdsEnd; ++achievementIdItr)
1415 {
1416 uint32 achievementId = *achievementIdItr;
1417 if (AchievementEntry const* achievement = sAchievementStore.LookupEntry(achievementId))
1418 {
1419 if (!(achievement->Flags & ACHIEVEMENT_FLAG_GUILD) || GetAchievementMgr().HasAchieved(achievementId))
1420 continue;
1421
1422 if (CriteriaTree const* tree = sCriteriaMgr->GetCriteriaTree(achievement->CriteriaTree))
1423 {
1424 CriteriaMgr::WalkCriteriaTree(tree, [&criteriaIds](CriteriaTree const* node)
1425 {
1426 if (node->Criteria)
1427 criteriaIds.insert(node->Criteria->ID);
1428 });
1429 }
1430 }
1431 }
1432
1433 member->SetTrackedCriteriaIds(std::move(criteriaIds));
1434 GetAchievementMgr().SendAllTrackedCriterias(player, member->GetTrackedCriteriaIds());
1435 }
1436}
#define sCriteriaMgr
DB2Storage< AchievementEntry > sAchievementStore("Achievement.db2", &AchievementLoadInfo::Instance)
@ ACHIEVEMENT_FLAG_GUILD
Definition: DBCEnums.h:98
static void WalkCriteriaTree(CriteriaTree const *tree, Func const &func)
void SendAllTrackedCriterias(Player *receiver, std::set< uint32 > const &trackedCriterias) const
bool HasAchieved(uint32 achievementId) const
Definition: Guild.cpp:3609
struct Criteria const * Criteria
+ Here is the call graph for this function:

◆ HandleSetBankTabInfo()

void Guild::HandleSetBankTabInfo ( WorldSession session,
uint8  tabId,
std::string_view  name,
std::string_view  icon 
)

Definition at line 1552 of file Guild.cpp.

1553{
1554 BankTab* tab = GetBankTab(tabId);
1555 if (!tab)
1556 {
1557 TC_LOG_ERROR("guild", "Guild::HandleSetBankTabInfo: Player {} trying to change bank tab info from unexisting tab {}.",
1558 session->GetPlayerInfo(), tabId);
1559 return;
1560 }
1561
1562 tab->SetInfo(name, icon);
1563
1565 packet.Tab = tabId;
1566 packet.Name = name;
1567 packet.Icon = icon;
1568 BroadcastPacket(packet.Write());
1569}
WorldPacket const * Write() override
+ Here is the call graph for this function:

◆ HandleSetEmblem()

void Guild::HandleSetEmblem ( WorldSession session,
EmblemInfo const &  emblemInfo 
)

Definition at line 1485 of file Guild.cpp.

1486{
1487 Player* player = session->GetPlayer();
1488 if (!_IsLeader(player))
1489 SendSaveEmblemResult(session, ERR_GUILDEMBLEM_NOTGUILDMASTER); // "Only guild leaders can create emblems."
1490 else if (!player->HasEnoughMoney(uint64(EMBLEM_PRICE)))
1491 SendSaveEmblemResult(session, ERR_GUILDEMBLEM_NOTENOUGHMONEY); // "You can't afford to do that."
1492 else
1493 {
1494 player->ModifyMoney(-int64(EMBLEM_PRICE));
1495
1496 m_emblemInfo = emblemInfo;
1498
1499 SendSaveEmblemResult(session, ERR_GUILDEMBLEM_SUCCESS); // "Guild Emblem saved."
1500
1501 SendQueryResponse(session);
1502 }
1503}
uint32 const EMBLEM_PRICE
Definition: Guild.cpp:46
@ ERR_GUILDEMBLEM_NOTGUILDMASTER
Definition: Guild.h:205
@ ERR_GUILDEMBLEM_NOTENOUGHMONEY
Definition: Guild.h:206
@ ERR_GUILDEMBLEM_SUCCESS
Definition: Guild.h:202
void SaveToDB(ObjectGuid::LowType guildId) const
Definition: Guild.cpp:760
void SendQueryResponse(WorldSession *session)
Definition: Guild.cpp:1353
static void SendSaveEmblemResult(WorldSession *session, GuildEmblemError errCode)
Definition: Guild.cpp:69
+ Here is the call graph for this function:

◆ HandleSetInfo()

void Guild::HandleSetInfo ( WorldSession session,
std::string_view  info 
)

Definition at line 1466 of file Guild.cpp.

1467{
1468 if (m_info == info)
1469 return;
1470
1471 // Player must have rights to set guild's info
1473 {
1474 m_info = info;
1475
1476 sScriptMgr->OnGuildInfoChanged(this, m_info);
1477
1479 stmt->setString(0, m_info);
1480 stmt->setUInt64(1, m_id);
1481 CharacterDatabase.Execute(stmt);
1482 }
1483}
@ CHAR_UPD_GUILD_INFO
@ GR_RIGHT_MODIFY_GUILD_INFO
Definition: Guild.h:102
+ Here is the call graph for this function:

◆ HandleSetMemberNote()

void Guild::HandleSetMemberNote ( WorldSession session,
std::string_view  note,
ObjectGuid  guid,
bool  isPublic 
)

Definition at line 1571 of file Guild.cpp.

1572{
1573 // Player must have rights to set public/officer note
1576 else if (Member* member = GetMember(guid))
1577 {
1578 if (isPublic)
1579 member->SetPublicNote(note);
1580 else
1581 member->SetOfficerNote(note);
1582
1584 updateNote.Member = guid;
1585 updateNote.IsPublic = isPublic;
1586 updateNote.Note = note;
1587 BroadcastPacket(updateNote.Write());
1588 }
1589}
@ GUILD_COMMAND_EDIT_PUBLIC_NOTE
Definition: Guild.h:124
@ GR_RIGHT_EOFFNOTE
Definition: Guild.h:101
@ GR_RIGHT_EDIT_PUBLIC_NOTE
Definition: Guild.h:99
WorldPacket const * Write() override
bool IsPublic
0 == Officer, 1 == Public
Definition: GuildPackets.h:573
+ Here is the call graph for this function:

◆ HandleSetMemberRank()

void Guild::HandleSetMemberRank ( WorldSession session,
ObjectGuid  guid,
ObjectGuid  setterGuid,
GuildRankOrder  rank 
)

Definition at line 1869 of file Guild.cpp.

1870{
1871 Player* player = session->GetPlayer();
1872 Member* member = GetMember(targetGuid);
1873 if (!member)
1874 return;
1877
1878 RankInfo const* oldRank = GetRankInfo(member->GetRankId());
1879 RankInfo const* newRank = GetRankInfo(rank);
1880 if (!oldRank || !newRank)
1881 return;
1882
1883 if (rank > oldRank->GetOrder())
1884 {
1885 rights = GR_RIGHT_DEMOTE;
1887 }
1888
1889 // Promoted player must be a member of guild
1890 if (!_HasRankRight(player, rights))
1891 {
1893 return;
1894 }
1895
1896 // Player cannot promote himself
1897 if (member->IsSamePlayer(player->GetGUID()))
1898 {
1900 return;
1901 }
1902
1903 SendGuildRanksUpdate(setterGuid, targetGuid, newRank->GetId());
1904}
GuildCommandType
Definition: Guild.h:111
@ GUILD_COMMAND_PROMOTE_PLAYER
Definition: Guild.h:116
@ GUILD_COMMAND_DEMOTE_PLAYER
Definition: Guild.h:117
@ ERR_GUILD_NAME_INVALID
Definition: Guild.h:138
GuildRankRights
Definition: Guild.h:84
@ GR_RIGHT_DEMOTE
Definition: Guild.h:94
@ GR_RIGHT_PROMOTE
Definition: Guild.h:93
void SendGuildRanksUpdate(ObjectGuid setterGuid, ObjectGuid targetGuid, GuildRankId rank)
Definition: Guild.cpp:3565
+ Here is the call graph for this function:

◆ HandleSetMOTD()

void Guild::HandleSetMOTD ( WorldSession session,
std::string_view  motd 
)

Definition at line 1443 of file Guild.cpp.

1444{
1445 if (m_motd == motd)
1446 return;
1447
1448 // Player must have rights to set MOTD
1449 if (!_HasRankRight(session->GetPlayer(), GR_RIGHT_SETMOTD))
1451 else
1452 {
1453 m_motd = motd;
1454
1455 sScriptMgr->OnGuildMOTDChanged(this, m_motd);
1456
1458 stmt->setString(0, m_motd);
1459 stmt->setUInt64(1, m_id);
1460 CharacterDatabase.Execute(stmt);
1461
1462 SendEventMOTD(session, true);
1463 }
1464}
@ CHAR_UPD_GUILD_MOTD
@ GUILD_COMMAND_EDIT_MOTD
Definition: Guild.h:120
@ GR_RIGHT_SETMOTD
Definition: Guild.h:98
void SendEventMOTD(WorldSession *session, bool broadcast=false) const
Definition: Guild.cpp:2337
+ Here is the call graph for this function:

◆ HandleSetNewGuildMaster()

void Guild::HandleSetNewGuildMaster ( WorldSession session,
std::string_view  name,
bool  isSelfPromote 
)

Definition at line 1505 of file Guild.cpp.

1506{
1507 Player* player = session->GetPlayer();
1508
1509 Member* oldGuildMaster = GetMember(GetLeaderGUID());
1510 ASSERT(oldGuildMaster);
1511
1512 Member* newGuildMaster;
1513
1514 if (isSelfPromote)
1515 {
1516 newGuildMaster = GetMember(player->GetGUID());
1517 if (!newGuildMaster)
1518 return;
1519
1520 RankInfo const* oldRank = GetRankInfo(newGuildMaster->GetRankId());
1521
1522 if (oldRank->GetOrder() != GuildRankOrder(1) // only second highest rank can take over guild
1523 || uint32(oldGuildMaster->GetInactiveDays()) < GUILD_MASTER_DETHRONE_INACTIVE_DAYS)
1524 {
1526 return;
1527 }
1528 }
1529 else
1530 {
1531 if (!_IsLeader(player))
1532 {
1534 return;
1535 }
1536
1537 newGuildMaster = GetMember(name);
1538 if (!newGuildMaster)
1539 return;
1540 }
1541
1542 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
1543
1544 _SetLeader(trans, *newGuildMaster);
1545 oldGuildMaster->ChangeRank(trans, _GetLowestRankId());
1546
1547 SendEventNewLeader(newGuildMaster, oldGuildMaster, isSelfPromote);
1548
1549 CharacterDatabase.CommitTransaction(trans);
1550}
@ GUILD_MASTER_DETHRONE_INACTIVE_DAYS
Definition: Guild.h:56
@ GUILD_COMMAND_CHANGE_LEADER
Definition: Guild.h:119
+ Here is the call graph for this function:

◆ HandleSetRankInfo()

void Guild::HandleSetRankInfo ( WorldSession session,
GuildRankId  rankId,
std::string_view  name,
uint32  rights,
uint32  moneyPerDay,
std::array< GuildBankRightsAndSlots, GUILD_BANK_MAX_TABS > const &  rightsAndSlots 
)

Definition at line 1591 of file Guild.cpp.

1592{
1593 // Only leader can modify ranks
1594 if (!_IsLeader(session->GetPlayer()))
1596 else if (RankInfo* rankInfo = GetRankInfo(rankId))
1597 {
1598 rankInfo->SetName(name);
1599 rankInfo->SetRights(rights);
1600 _SetRankBankMoneyPerDay(rankId, moneyPerDay * GOLD);
1601
1602 for (auto itr = rightsAndSlots.begin(); itr != rightsAndSlots.end(); ++itr)
1603 _SetRankBankTabRightsAndSlots(rankId, *itr);
1604
1606 packet.RankID = AsUnderlyingType(rankId);
1607 BroadcastPacket(packet.Write());
1608 }
1609}
@ GUILD_COMMAND_CHANGE_RANK
Definition: Guild.h:123
void _SetRankBankTabRightsAndSlots(GuildRankId rankId, GuildBankRightsAndSlots rightsAndSlots, bool saveToDB=true)
Definition: Guild.cpp:3155
void _SetRankBankMoneyPerDay(GuildRankId rankId, uint32 moneyPerDay)
Definition: Guild.cpp:3149
WorldPacket const * Write() override
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandleShiftRank()

void Guild::HandleShiftRank ( WorldSession session,
GuildRankOrder  rankOrder,
bool  shiftUp 
)

Definition at line 1975 of file Guild.cpp.

1976{
1977 // Only leader can modify ranks
1978 if (!_IsLeader(session->GetPlayer()))
1979 return;
1980
1981 GuildRankOrder otherRankOrder = GuildRankOrder(AsUnderlyingType(rankOrder) + (shiftUp ? -1 : 1));
1982
1983 RankInfo* rankInfo = GetRankInfo(rankOrder);
1984 RankInfo* otherRankInfo = GetRankInfo(otherRankOrder);
1985 if (!rankInfo || !otherRankInfo)
1986 return;
1987
1988 // can't shift guild master rank (rank id = 0) - there's already a client-side limitation for it so that's just a safe-guard
1989 if (rankInfo->GetId() == GuildRankId::GuildMaster || otherRankInfo->GetId() == GuildRankId::GuildMaster)
1990 return;
1991
1992 rankInfo->SetOrder(otherRankOrder);
1993 otherRankInfo->SetOrder(rankOrder);
1994
1995 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
1996
1998 stmt->setUInt8(0, AsUnderlyingType(rankInfo->GetOrder()));
1999 stmt->setUInt8(1, AsUnderlyingType(rankInfo->GetId()));
2000 stmt->setUInt64(2, m_id);
2001 trans->Append(stmt);
2002
2003 stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_RANK_ORDER);
2004 stmt->setUInt8(0, AsUnderlyingType(otherRankInfo->GetOrder()));
2005 stmt->setUInt8(1, AsUnderlyingType(otherRankInfo->GetId()));
2006 stmt->setUInt64(2, m_id);
2007 trans->Append(stmt);
2008
2009 CharacterDatabase.CommitTransaction(trans);
2010
2011 // force client to re-request SMSG_GUILD_RANKS
2013}
+ Here is the call graph for this function:

◆ HandleUpdateMemberRank()

void Guild::HandleUpdateMemberRank ( WorldSession session,
ObjectGuid  guid,
bool  demote 
)

Definition at line 1808 of file Guild.cpp.

1809{
1810 Player* player = session->GetPlayer();
1812 // Player must have rights to promote
1813 if (!_HasRankRight(player, demote ? GR_RIGHT_DEMOTE : GR_RIGHT_PROMOTE))
1815 // Promoted player must be a member of guild
1816 else if (Member* member = GetMember(guid))
1817 {
1818 std::string name = member->GetName();
1819 // Player cannot promote himself
1820 if (member->IsSamePlayer(player->GetGUID()))
1821 {
1823 return;
1824 }
1825
1826 Member const* memberMe = GetMember(player->GetGUID());
1827 ASSERT(memberMe);
1828 RankInfo const* myRank = GetRankInfo(memberMe->GetRankId());
1829 RankInfo const* oldRank = GetRankInfo(member->GetRankId());
1830 GuildRankId newRankId;
1831 if (demote)
1832 {
1833 // Player can demote only lower rank members
1834 if (oldRank->GetOrder() <= myRank->GetOrder())
1835 {
1836 SendCommandResult(session, type, ERR_GUILD_RANK_TOO_HIGH_S, name);
1837 return;
1838 }
1839 // Lowest rank cannot be demoted
1840 RankInfo const* newRank = GetRankInfo(GuildRankOrder(AsUnderlyingType(oldRank->GetOrder()) + 1));
1841 if (!newRank)
1842 {
1843 SendCommandResult(session, type, ERR_GUILD_RANK_TOO_LOW_S, name);
1844 return;
1845 }
1846
1847 newRankId = newRank->GetId();
1848 }
1849 else
1850 {
1851 // Allow to promote only to lower rank than member's rank
1852 // memberMe->GetRankId() + 1 is the highest rank that current player can promote to
1853 if (GuildRankOrder(AsUnderlyingType(oldRank->GetOrder()) - 1) <= myRank->GetOrder())
1854 {
1855 SendCommandResult(session, type, ERR_GUILD_RANK_TOO_HIGH_S, name);
1856 return;
1857 }
1858
1859 newRankId = ASSERT_NOTNULL(GetRankInfo(GuildRankOrder(AsUnderlyingType(oldRank->GetOrder()) - 1)))->GetId();
1860 }
1861
1862 CharacterDatabaseTransaction trans(nullptr);
1863 member->ChangeRank(trans, newRankId);
1864 _LogEvent(demote ? GUILD_EVENT_LOG_DEMOTE_PLAYER : GUILD_EVENT_LOG_PROMOTE_PLAYER, player->GetGUID().GetCounter(), member->GetGUID().GetCounter(), AsUnderlyingType(newRankId));
1865 //_BroadcastEvent(demote ? GE_DEMOTION : GE_PROMOTION, ObjectGuid::Empty, player->GetName().c_str(), name.c_str(), _GetRankName(newRankId).c_str());
1866 }
1867}
#define ASSERT_NOTNULL(pointer)
Definition: Errors.h:84
@ ERR_GUILD_RANK_TOO_LOW_S
Definition: Guild.h:147
@ GUILD_EVENT_LOG_PROMOTE_PLAYER
Definition: Guild.h:194
@ GUILD_EVENT_LOG_DEMOTE_PLAYER
Definition: Guild.h:195
+ Here is the call graph for this function:

◆ HasAchieved()

bool Guild::HasAchieved ( uint32  achievementId) const

Definition at line 3609 of file Guild.cpp.

3610{
3611 return GetAchievementMgr().HasAchieved(achievementId);
3612}
bool HasAchieved(uint32 achievementId) const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsMember()

bool Guild::IsMember ( ObjectGuid  guid) const

Definition at line 2894 of file Guild.cpp.

2895{
2896 return m_members.find(guid) != m_members.end();
2897}
+ Here is the caller graph for this function:

◆ LoadBankEventLogFromDB()

bool Guild::LoadBankEventLogFromDB ( Field fields)

Definition at line 2496 of file Guild.cpp.

2497{
2498 uint8 dbTabId = fields[1].GetUInt8();
2499 bool isMoneyTab = (dbTabId == GUILD_BANK_MONEY_LOGS_TAB);
2500 if (dbTabId < _GetPurchasedTabsSize() || isMoneyTab)
2501 {
2502 uint8 tabId = isMoneyTab ? uint8(GUILD_BANK_MAX_TABS) : dbTabId;
2503 LogHolder<BankEventLogEntry>& bankLog = m_bankEventLog[tabId];
2504 if (bankLog.CanInsert())
2505 {
2506 uint32 guid = fields[2].GetUInt32();
2507 GuildBankEventLogTypes eventType = GuildBankEventLogTypes(fields[3].GetUInt8());
2508 if (BankEventLogEntry::IsMoneyEvent(eventType))
2509 {
2510 if (!isMoneyTab)
2511 {
2512 TC_LOG_ERROR("guild", "GuildBankEventLog ERROR: MoneyEvent(LogGuid: {}, Guild: {}) does not belong to money tab ({}), ignoring...", guid, m_id, dbTabId);
2513 return false;
2514 }
2515 }
2516 else if (isMoneyTab)
2517 {
2518 TC_LOG_ERROR("guild", "GuildBankEventLog ERROR: non-money event (LogGuid: {}, Guild: {}) belongs to money tab, ignoring...", guid, m_id);
2519 return false;
2520 }
2521 bankLog.LoadEvent(
2522 m_id, // guild id
2523 guid, // guid
2524 fields[8].GetInt64(), // timestamp
2525 dbTabId, // tab id
2526 eventType, // event type
2527 fields[4].GetUInt64(), // player guid
2528 fields[5].GetUInt64(), // item or money
2529 fields[6].GetUInt16(), // itam stack count
2530 fields[7].GetUInt8()); // dest tab id
2531 }
2532 }
2533 return true;
2534}
GuildBankEventLogTypes
Definition: Guild.h:177
uint8 GetUInt8() const
Definition: Field.cpp:30
uint32 GetUInt32() const
Definition: Field.cpp:62
+ Here is the call graph for this function:

◆ LoadBankItemFromDB()

bool Guild::LoadBankItemFromDB ( Field fields)

Definition at line 2560 of file Guild.cpp.

2561{
2562 uint8 tabId = fields[52].GetUInt8();
2563 if (tabId >= _GetPurchasedTabsSize())
2564 {
2565 TC_LOG_ERROR("guild", "Invalid tab for item (GUID: {}, id: #{}) in guild bank, skipped.",
2566 fields[0].GetUInt32(), fields[1].GetUInt32());
2567 return false;
2568 }
2569 return m_bankTabs[tabId].LoadItemFromDB(fields);
2570}
+ Here is the call graph for this function:

◆ LoadBankRightFromDB()

void Guild::LoadBankRightFromDB ( Field fields)

Definition at line 2471 of file Guild.cpp.

2472{
2473 // tabId rights slots
2474 GuildBankRightsAndSlots rightsAndSlots(fields[1].GetUInt8(), fields[3].GetInt8(), fields[4].GetInt32());
2475 // rankId
2476 _SetRankBankTabRightsAndSlots(GuildRankId(fields[2].GetUInt8()), rightsAndSlots, false);
2477}
+ Here is the call graph for this function:

◆ LoadBankTabFromDB()

void Guild::LoadBankTabFromDB ( Field fields)

Definition at line 2551 of file Guild.cpp.

2552{
2553 uint8 tabId = fields[1].GetUInt8();
2554 if (tabId >= _GetPurchasedTabsSize())
2555 TC_LOG_ERROR("guild", "Invalid tab (tabId: {}) in guild bank, skipped.", tabId);
2556 else
2557 m_bankTabs[tabId].LoadFromDB(fields);
2558}
+ Here is the call graph for this function:

◆ LoadEventLogFromDB()

bool Guild::LoadEventLogFromDB ( Field fields)

Definition at line 2479 of file Guild.cpp.

2480{
2481 if (m_eventLog.CanInsert())
2482 {
2483 m_eventLog.LoadEvent(
2484 m_id, // guild id
2485 fields[1].GetUInt32(), // guid
2486 fields[6].GetInt64(), // timestamp
2487 GuildEventLogTypes(fields[2].GetUInt8()), // event type
2488 fields[3].GetUInt64(), // player guid 1
2489 fields[4].GetUInt64(), // player guid 2
2490 fields[5].GetUInt8()); // rank
2491 return true;
2492 }
2493 return false;
2494}
GuildEventLogTypes
Definition: Guild.h:191

◆ LoadFromDB()

bool Guild::LoadFromDB ( Field fields)

Definition at line 2408 of file Guild.cpp.

2409{
2410 m_id = fields[0].GetUInt64();
2411 m_name = fields[1].GetString();
2412 m_leaderGuid = ObjectGuid::Create<HighGuid::Player>(fields[2].GetUInt64());
2413
2414 if (!m_emblemInfo.LoadFromDB(fields))
2415 {
2416 TC_LOG_ERROR("guild", "Guild {} has invalid emblem colors (Background: {}, Border: {}, Emblem: {}), skipped.",
2418 return false;
2419 }
2420
2421 m_info = fields[8].GetString();
2422 m_motd = fields[9].GetString();
2423 m_createdDate = time_t(fields[10].GetUInt32());
2424 m_bankMoney = fields[11].GetUInt64();
2425
2426 uint8 purchasedTabs = uint8(fields[12].GetUInt64());
2427 if (purchasedTabs > GUILD_BANK_MAX_TABS)
2428 purchasedTabs = GUILD_BANK_MAX_TABS;
2429
2430 m_bankTabs.clear();
2431 m_bankTabs.reserve(purchasedTabs);
2432 for (uint8 i = 0; i < purchasedTabs; ++i)
2433 m_bankTabs.emplace_back(m_id, i);
2434 return true;
2435}
bool LoadFromDB(Field *fields)
Definition: Guild.cpp:749
uint64 GetUInt64() const
Definition: Field.cpp:78
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LoadGuildNewsLogFromDB()

void Guild::LoadGuildNewsLogFromDB ( Field fields)

Definition at line 2536 of file Guild.cpp.

2537{
2538 if (!m_newsLog.CanInsert())
2539 return;
2540
2541 m_newsLog.LoadEvent(
2542 m_id, // guild id
2543 fields[1].GetUInt32(), // guid
2544 fields[6].GetInt64(), // timestamp //64 bits?
2545 GuildNews(fields[2].GetUInt8()), // type
2546 ObjectGuid::Create<HighGuid::Player>(fields[3].GetUInt64()), // player guid
2547 fields[4].GetUInt32(), // Flags
2548 fields[5].GetUInt32()); // value
2549}

◆ LoadMemberFromDB()

bool Guild::LoadMemberFromDB ( Field fields)

Definition at line 2446 of file Guild.cpp.

2447{
2448 ObjectGuid::LowType lowguid = fields[1].GetUInt64();
2449 ObjectGuid playerGuid(ObjectGuid::Create<HighGuid::Player>(lowguid));
2450
2451 auto [memberIt, isNew] = m_members.try_emplace(playerGuid, m_id, playerGuid, GuildRankId(fields[2].GetUInt8()));
2452 if (!isNew)
2453 {
2454 TC_LOG_ERROR("guild", "Tried to add {} to guild '{}'. Member already exists.", playerGuid.ToString(), m_name);
2455 return false;
2456 }
2457
2458 Member& member = memberIt->second;
2459 if (!member.LoadFromDB(fields))
2460 {
2461 CharacterDatabaseTransaction trans(nullptr);
2462 Guild::_DeleteMemberFromDB(trans, lowguid);
2463 m_members.erase(memberIt);
2464 return false;
2465 }
2466
2467 sCharacterCache->UpdateCharacterGuildId(playerGuid, GetId());
2468 return true;
2469}
+ Here is the call graph for this function:

◆ LoadRankFromDB()

void Guild::LoadRankFromDB ( Field fields)

Definition at line 2437 of file Guild.cpp.

2438{
2439 RankInfo rankInfo(m_id);
2440
2441 rankInfo.LoadFromDB(fields);
2442
2443 m_ranks.push_back(rankInfo);
2444}
+ Here is the call graph for this function:

◆ MassInviteToEvent()

void Guild::MassInviteToEvent ( WorldSession session,
uint32  minLevel,
uint32  maxLevel,
GuildRankOrder  minRank 
)

Definition at line 2700 of file Guild.cpp.

2701{
2703
2704 for (auto const& [guid, member] : m_members)
2705 {
2706 // not sure if needed, maybe client checks it as well
2707 if (packet.Invites.size() >= CALENDAR_MAX_INVITES)
2708 {
2709 if (Player* player = session->GetPlayer())
2710 sCalendarMgr->SendCalendarCommandResult(player->GetGUID(), CALENDAR_ERROR_INVITES_EXCEEDED);
2711 return;
2712 }
2713
2714 if (guid == session->GetPlayer()->GetGUID())
2715 continue;
2716
2717 uint32 level = sCharacterCache->GetCharacterLevelByGuid(guid);
2718 if (level < minLevel || level > maxLevel)
2719 continue;
2720
2721 RankInfo const* rank = GetRankInfo(member.GetRankId());
2722 if (rank->GetOrder() > minRank)
2723 continue;
2724
2725 packet.Invites.emplace_back(guid, level);
2726 }
2727
2728 session->SendPacket(packet.Write());
2729}
@ CALENDAR_ERROR_INVITES_EXCEEDED
Definition: CalendarMgr.h:109
@ CALENDAR_MAX_INVITES
Definition: CalendarMgr.h:135
std::vector< CalendarEventInitialInviteInfo > Invites
+ Here is the call graph for this function:

◆ OnPlayerStatusChange()

void Guild::OnPlayerStatusChange ( Player player,
uint32  flag,
bool  state 
)

Definition at line 1276 of file Guild.cpp.

1277{
1278 if (Member* member = GetMember(player->GetGUID()))
1279 {
1280 if (state)
1281 member->AddFlag(flag);
1282 else member->RemFlag(flag);
1283 }
1284}
+ Here is the call graph for this function:

◆ ResetTimes()

void Guild::ResetTimes ( bool  weekly)

Definition at line 3584 of file Guild.cpp.

3585{
3586 for (auto& [guid, member] : m_members)
3587 {
3588 member.ResetValues(weekly);
3589 if (Player* player = member.FindPlayer())
3590 {
3591 WorldPackets::Guild::GuildMemberDailyReset packet; // tells the client to request bank withdrawal limit
3592 player->GetSession()->SendPacket(packet.Write());
3593 }
3594 }
3595}
WorldPacket const * Write() override
Definition: GuildPackets.h:582
+ Here is the call graph for this function:

◆ SaveToDB()

void Guild::SaveToDB ( )

Definition at line 1244 of file Guild.cpp.

1245{
1246 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
1247
1248 GetAchievementMgr().SaveToDB(trans);
1249
1250 CharacterDatabase.CommitTransaction(trans);
1251}
void SaveToDB(CharacterDatabaseTransaction trans)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendBankList()

void Guild::SendBankList ( WorldSession session,
uint8  tabId,
bool  fullUpdate 
) const

Definition at line 3489 of file Guild.cpp.

3490{
3491 Member const* member = GetMember(session->GetPlayer()->GetGUID());
3492 if (!member) // Shouldn't happen, just in case
3493 return;
3494
3496
3497 packet.Money = m_bankMoney;
3498 packet.WithdrawalsRemaining = _GetMemberRemainingSlots(*member, tabId);
3499 packet.Tab = int32(tabId);
3500 packet.FullUpdate = fullUpdate;
3501
3502 // TabInfo
3503 if (fullUpdate)
3504 {
3505 packet.TabInfo.reserve(_GetPurchasedTabsSize());
3506 for (uint8 i = 0; i < _GetPurchasedTabsSize(); ++i)
3507 {
3508 WorldPackets::Guild::GuildBankTabInfo& tabInfo = packet.TabInfo.emplace_back();
3509 tabInfo.TabIndex = i;
3510 tabInfo.Name = m_bankTabs[i].GetName();
3511 tabInfo.Icon = m_bankTabs[i].GetIcon();
3512 }
3513 }
3514
3515 // ItemInfo
3516 uint32 itemCount = 0;
3517 if (fullUpdate && _MemberHasTabRights(session->GetPlayer()->GetGUID(), tabId, GUILD_BANK_RIGHT_VIEW_TAB))
3518 if (BankTab const* tab = GetBankTab(tabId))
3519 for (uint8 slotId = 0; slotId < GUILD_BANK_MAX_SLOTS; ++slotId)
3520 if (tab->GetItem(slotId))
3521 ++itemCount;
3522
3523 packet.ItemInfo.reserve(itemCount);
3524
3525 if (fullUpdate && _MemberHasTabRights(session->GetPlayer()->GetGUID(), tabId, GUILD_BANK_RIGHT_VIEW_TAB))
3526 {
3527 if (BankTab const* tab = GetBankTab(tabId))
3528 {
3529 for (uint8 slotId = 0; slotId < GUILD_BANK_MAX_SLOTS; ++slotId)
3530 {
3531 if (Item* tabItem = tab->GetItem(slotId))
3532 {
3533 WorldPackets::Guild::GuildBankItemInfo& itemInfo = packet.ItemInfo.emplace_back();
3534
3535 itemInfo.Slot = int32(slotId);
3536 itemInfo.Item.ItemID = tabItem->GetEntry();
3537 itemInfo.Count = int32(tabItem->GetCount());
3538 itemInfo.Charges = int32(abs(tabItem->GetSpellCharges()));
3539 itemInfo.EnchantmentID = int32(tabItem->GetEnchantmentId(PERM_ENCHANTMENT_SLOT));
3540 itemInfo.OnUseEnchantmentID = int32(tabItem->GetEnchantmentId(USE_ENCHANTMENT_SLOT));
3541 itemInfo.Flags = tabItem->m_itemData->DynamicFlags;
3542
3543 uint8 i = 0;
3544 for (UF::SocketedGem const& gemData : tabItem->m_itemData->Gems)
3545 {
3546 if (gemData.ItemID)
3547 {
3549 gem.Slot = i;
3550 gem.Item.Initialize(&gemData);
3551 itemInfo.SocketEnchant.push_back(gem);
3552 }
3553 ++i;
3554 }
3555
3556 itemInfo.Locked = false;
3557 }
3558 }
3559 }
3560 }
3561
3562 session->SendPacket(packet.Write());
3563}
@ GUILD_BANK_MAX_SLOTS
Definition: Guild.h:54
std::vector< GuildBankTabInfo > TabInfo
Definition: GuildPackets.h:821
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendBankLog()

void Guild::SendBankLog ( WorldSession session,
uint8  tabId 
) const

Definition at line 2194 of file Guild.cpp.

2195{
2196 // GUILD_BANK_MAX_TABS send by client for money log
2197 if (tabId < _GetPurchasedTabsSize() || tabId == GUILD_BANK_MAX_TABS)
2198 {
2199 std::list<BankEventLogEntry> const& bankEventLog = m_bankEventLog[tabId].GetGuildLog();
2200
2202 packet.Tab = int32(tabId);
2203
2204 //if (tabId == GUILD_BANK_MAX_TABS && hasCashFlow)
2205 // packet.WeeklyBonusMoney.Set(uint64(weeklyBonusMoney));
2206
2207 packet.Entry.reserve(bankEventLog.size());
2208 for (BankEventLogEntry const& entry : bankEventLog)
2209 entry.WritePacket(packet);
2210
2211 session->SendPacket(packet.Write());
2212
2213 TC_LOG_DEBUG("guild", "SMSG_GUILD_BANK_LOG_QUERY_RESULT [{}] TabId: {}", session->GetPlayerInfo(), tabId);
2214 }
2215}
std::vector< GuildBankLogEntry > Entry
WorldPacket const * Write() override
+ Here is the call graph for this function:

◆ SendBankTabText()

void Guild::SendBankTabText ( WorldSession session,
uint8  tabId 
) const

Definition at line 2217 of file Guild.cpp.

2218{
2219 if (BankTab const* tab = GetBankTab(tabId))
2220 tab->SendText(this, session);
2221}
+ Here is the call graph for this function:

◆ SendCommandResult()

void Guild::SendCommandResult ( WorldSession session,
GuildCommandType  type,
GuildCommandError  errCode,
std::string_view  param = "" 
)
static

Definition at line 57 of file Guild.cpp.

58{
60 resultPacket.Command = type;
61 resultPacket.Result = errCode;
62 resultPacket.Name = param;
63 session->SendPacket(resultPacket.Write());
64
65 TC_LOG_DEBUG("guild", "SMSG_GUILD_COMMAND_RESULT [{}]: Type: {}, code: {}, param: {}"
66 , session->GetPlayerInfo(), type, errCode, resultPacket.Name);
67}
WorldPacket const * Write() override
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendEventAwayChanged()

void Guild::SendEventAwayChanged ( ObjectGuid const &  memberGuid,
bool  afk,
bool  dnd 
)

Definition at line 2307 of file Guild.cpp.

2308{
2309 Member* member = GetMember(memberGuid);
2310 if (!member)
2311 return;
2312
2313 if (afk)
2314 member->AddFlag(GUILDMEMBER_STATUS_AFK);
2315 else
2316 member->RemFlag(GUILDMEMBER_STATUS_AFK);
2317
2318 if (dnd)
2319 member->AddFlag(GUILDMEMBER_STATUS_DND);
2320 else
2321 member->RemFlag(GUILDMEMBER_STATUS_DND);
2322
2324 statusChange.Guid = memberGuid;
2325 statusChange.AFK = afk;
2326 statusChange.DND = dnd;
2327 BroadcastPacket(statusChange.Write());
2328}
@ GUILDMEMBER_STATUS_AFK
Definition: Guild.h:214
@ GUILDMEMBER_STATUS_DND
Definition: Guild.h:215
WorldPacket const * Write() override
+ Here is the call graph for this function:

◆ SendEventBankMoneyChanged()

void Guild::SendEventBankMoneyChanged ( ) const

Definition at line 2330 of file Guild.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendEventLog()

void Guild::SendEventLog ( WorldSession session) const

Definition at line 2164 of file Guild.cpp.

2165{
2166 std::list<EventLogEntry> const& eventLog = m_eventLog.GetGuildLog();
2167
2169 packet.Entry.reserve(eventLog.size());
2170
2171 for (EventLogEntry const& entry : eventLog)
2172 entry.WritePacket(packet);
2173
2174 session->SendPacket(packet.Write());
2175
2176 TC_LOG_DEBUG("guild", "SMSG_GUILD_EVENT_LOG_QUERY_RESULTS [{}]", session->GetPlayerInfo());
2177}
std::vector< GuildEventEntry > Entry
Definition: GuildPackets.h:338
+ Here is the call graph for this function:

◆ SendEventMOTD()

void Guild::SendEventMOTD ( WorldSession session,
bool  broadcast = false 
) const

Definition at line 2337 of file Guild.cpp.

2338{
2340 eventPacket.MotdText = GetMOTD();
2341
2342 if (broadcast)
2343 BroadcastPacket(eventPacket.Write());
2344 else
2345 {
2346 session->SendPacket(eventPacket.Write());
2347 TC_LOG_DEBUG("guild", "SMSG_GUILD_EVENT_MOTD [{}] ", session->GetPlayerInfo());
2348 }
2349}
std::string const & GetMOTD() const
Definition: Guild.h:733
WorldPacket const * Write() override
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendEventNewLeader()

void Guild::SendEventNewLeader ( Member newLeader,
Member oldLeader,
bool  isSelfPromoted = false 
) const

Definition at line 2351 of file Guild.cpp.

2352{
2354 eventPacket.SelfPromoted = isSelfPromoted;
2355 if (newLeader)
2356 {
2357 eventPacket.NewLeaderGUID = newLeader->GetGUID();
2358 eventPacket.NewLeaderName = newLeader->GetName();
2360 }
2361
2362 if (oldLeader)
2363 {
2364 eventPacket.OldLeaderGUID = oldLeader->GetGUID();
2365 eventPacket.OldLeaderName = oldLeader->GetName();
2367 }
2368
2369 BroadcastPacket(eventPacket.Write());
2370}
WorldPacket const * Write() override
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendEventPlayerLeft()

void Guild::SendEventPlayerLeft ( Member leaver,
Member remover = nullptr,
bool  isRemoved = false 
) const

Definition at line 2372 of file Guild.cpp.

2373{
2375 eventPacket.Removed = isRemoved;
2376 eventPacket.LeaverGUID = leaver->GetGUID();
2377 eventPacket.LeaverName = leaver->GetName();
2379
2380 if (isRemoved && remover != nullptr)
2381 {
2382 eventPacket.RemoverGUID = remover->GetGUID();
2383 eventPacket.RemoverName = remover->GetName();
2385 }
2386
2387 BroadcastPacket(eventPacket.Write());
2388}
WorldPacket const * Write() override
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendEventPresenceChanged()

void Guild::SendEventPresenceChanged ( WorldSession session,
bool  loggedOn,
bool  broadcast = false 
) const

Definition at line 2390 of file Guild.cpp.

2391{
2392 Player* player = session->GetPlayer();
2393
2395 eventPacket.Guid = player->GetGUID();
2396 eventPacket.Name = player->GetName();
2398 eventPacket.LoggedOn = loggedOn;
2399 eventPacket.Mobile = false;
2400
2401 if (broadcast)
2402 BroadcastPacket(eventPacket.Write());
2403 else
2404 session->SendPacket(eventPacket.Write());
2405}
WorldPacket const * Write() override
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendGuildRankInfo()

void Guild::SendGuildRankInfo ( WorldSession session) const

Definition at line 1377 of file Guild.cpp.

1378{
1380
1381 ranks.Ranks.reserve(_GetRanksSize());
1382
1383 for (RankInfo const& rankInfo : m_ranks)
1384 {
1386
1387 rankData.RankID = AsUnderlyingType(rankInfo.GetId());
1388 rankData.RankOrder = AsUnderlyingType(rankInfo.GetOrder());
1389 rankData.Flags = rankInfo.GetRights();
1390 rankData.WithdrawGoldLimit = (rankInfo.GetId() == GuildRankId::GuildMaster ? (-1) : int32(rankInfo.GetBankMoneyPerDay() / GOLD));
1391 rankData.RankName = rankInfo.GetName();
1392
1393 for (uint8 j = 0; j < GUILD_BANK_MAX_TABS; ++j)
1394 {
1395 rankData.TabFlags[j] = uint32(rankInfo.GetBankTabRights(j));
1396 rankData.TabWithdrawItemLimit[j] = uint32(rankInfo.GetBankTabSlotsPerDay(j));
1397 }
1398
1399 ranks.Ranks.push_back(rankData);
1400 }
1401
1402 session->SendPacket(ranks.Write());
1403 TC_LOG_DEBUG("guild", "SMSG_GUILD_RANK [{}]", session->GetPlayerInfo());
1404}
WorldPacket const * Write() override
std::vector< GuildRankData > Ranks
Definition: GuildPackets.h:516
uint32 TabWithdrawItemLimit[GUILD_BANK_MAX_TABS]
Definition: GuildPackets.h:506
uint32 TabFlags[GUILD_BANK_MAX_TABS]
Definition: GuildPackets.h:505
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendGuildRanksUpdate()

void Guild::SendGuildRanksUpdate ( ObjectGuid  setterGuid,
ObjectGuid  targetGuid,
GuildRankId  rank 
)
private

Definition at line 3565 of file Guild.cpp.

3566{
3567 Member* member = GetMember(targetGuid);
3568 ASSERT(member);
3569
3571 rankChange.Officer = setterGuid;
3572 rankChange.Other = targetGuid;
3573 rankChange.RankID = AsUnderlyingType(rank);
3574 rankChange.Promote = (rank < member->GetRankId());
3575 BroadcastPacket(rankChange.Write());
3576
3578 member->ChangeRank(trans, rank);
3579
3580 TC_LOG_DEBUG("network", "SMSG_GUILD_RANKS_UPDATE [Broadcast] Target: {}, Issuer: {}, RankId: {}",
3581 targetGuid.ToString(), setterGuid.ToString(), uint32(rank));
3582}
WorldPacket const * Write() override
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendLoginInfo()

void Guild::SendLoginInfo ( WorldSession session)

Definition at line 2264 of file Guild.cpp.

2265{
2266 Player* player = session->GetPlayer();
2267 Member* member = GetMember(player->GetGUID());
2268 if (!member)
2269 return;
2270
2271 /*
2272 Login sequence:
2273 SMSG_GUILD_EVENT_MOTD
2274 SMSG_GUILD_RANK
2275 SMSG_GUILD_EVENT_PRESENCE_CHANGE - LoggedOn: True
2276 -- learn perks
2277 SMSG_ALL_GUILD_ACHIEVEMENTS
2278 SMSG_GUILD_MEMBER_DAILY_RESET // bank withdrawal reset
2279 */
2280
2281 SendEventMOTD(session);
2282 SendGuildRankInfo(session);
2283 SendEventPresenceChanged(session, true, true); // Broadcast
2284
2285 // Send to self separately, player is not in world yet and is not found by _BroadcastEvent
2286 SendEventPresenceChanged(session, true);
2287
2288 if (member->GetGUID() == GetLeaderGUID())
2289 {
2291 renameFlag.FlagSet = false;
2292 player->GetSession()->SendPacket(renameFlag.Write());
2293 }
2294
2295 for (GuildPerkSpellsEntry const* entry : sGuildPerkSpellsStore)
2296 player->LearnSpell(entry->SpellID, true);
2297
2299
2300 WorldPackets::Guild::GuildMemberDailyReset packet; // tells the client to request bank withdrawal limit
2301 player->GetSession()->SendPacket(packet.Write());
2302
2303 member->SetStats(player);
2304 member->AddFlag(GUILDMEMBER_STATUS_ONLINE);
2305}
@ GUILDMEMBER_STATUS_ONLINE
Definition: Guild.h:213
void SendAllData(Player const *receiver) const override
void SendGuildRankInfo(WorldSession *session) const
Definition: Guild.cpp:1377
void LearnSpell(uint32 spell_id, bool dependent, int32 fromSkill=0, bool suppressMessaging=false, Optional< int32 > traitDefinitionId={})
Definition: Player.cpp:3237
WorldPacket const * Write() override
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendMoneyInfo()

void Guild::SendMoneyInfo ( WorldSession session) const

Definition at line 2249 of file Guild.cpp.

2250{
2251 Member const* member = GetMember(session->GetPlayer()->GetGUID());
2252 if (!member)
2253 return;
2254
2255 int64 amount = _GetMemberRemainingMoney(*member);
2256
2258 packet.RemainingWithdrawMoney = amount;
2259 session->SendPacket(packet.Write());
2260
2261 TC_LOG_DEBUG("guild", "SMSG_GUILD_BANK_MONEY_WITHDRAWN [{}] Money: " SI64FMTD, session->GetPlayerInfo(), amount);
2262}
#define SI64FMTD
Definition: Define.h:130
+ Here is the call graph for this function:

◆ SendNewsUpdate()

void Guild::SendNewsUpdate ( WorldSession session) const

Definition at line 2179 of file Guild.cpp.

2180{
2181 std::list<NewsLogEntry> const& newsLog = m_newsLog.GetGuildLog();
2182
2184 packet.NewsEvents.reserve(newsLog.size());
2185
2186 for (NewsLogEntry const& newsLogEntry : newsLog)
2187 newsLogEntry.WritePacket(packet);
2188
2189 session->SendPacket(packet.Write());
2190
2191 TC_LOG_DEBUG("guild", "SMSG_GUILD_NEWS_UPDATE [{}]", session->GetPlayerInfo());
2192}
+ Here is the call graph for this function:

◆ SendPermissions()

void Guild::SendPermissions ( WorldSession session) const

Definition at line 2223 of file Guild.cpp.

2224{
2225 Member const* member = GetMember(session->GetPlayer()->GetGUID());
2226 if (!member)
2227 return;
2228
2229 GuildRankId rankId = member->GetRankId();
2230
2232 queryResult.RankID = AsUnderlyingType(rankId);
2233 queryResult.WithdrawGoldLimit = _GetRankBankMoneyPerDay(rankId);
2234 queryResult.Flags = _GetRankRights(rankId);
2235 queryResult.NumTabs = _GetPurchasedTabsSize();
2236 queryResult.Tab.reserve(GUILD_BANK_MAX_TABS);
2237
2238 for (uint8 tabId = 0; tabId < GUILD_BANK_MAX_TABS; ++tabId)
2239 {
2241 tabPerm.Flags = _GetRankBankTabRights(rankId, tabId);
2242 tabPerm.WithdrawItemLimit = _GetMemberRemainingSlots(*member, tabId);
2243 }
2244
2245 session->SendPacket(queryResult.Write());
2246 TC_LOG_DEBUG("guild", "SMSG_GUILD_PERMISSIONS_QUERY_RESULTS [{}] Rank: {}", session->GetPlayerInfo(), uint32(rankId));
2247}
std::vector< GuildRankTabPermissions > Tab
Definition: GuildPackets.h:436
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendQueryResponse()

void Guild::SendQueryResponse ( WorldSession session)

Definition at line 1353 of file Guild.cpp.

1354{
1356 response.GuildGuid = GetGUID();
1357 response.Info.emplace();
1358
1359 response.Info->GuildGUID = GetGUID();
1360 response.Info->VirtualRealmAddress = GetVirtualRealmAddress();
1361
1362 response.Info->EmblemStyle = m_emblemInfo.GetStyle();
1363 response.Info->EmblemColor = m_emblemInfo.GetColor();
1364 response.Info->BorderStyle = m_emblemInfo.GetBorderStyle();
1365 response.Info->BorderColor = m_emblemInfo.GetBorderColor();
1366 response.Info->BackgroundColor = m_emblemInfo.GetBackgroundColor();
1367
1368 for (RankInfo const& rankInfo : m_ranks)
1369 response.Info->Ranks.emplace_back(AsUnderlyingType(rankInfo.GetId()), AsUnderlyingType(rankInfo.GetOrder()), rankInfo.GetName());
1370
1371 response.Info->GuildName = m_name;
1372
1373 session->SendPacket(response.Write());
1374 TC_LOG_DEBUG("guild", "SMSG_GUILD_QUERY_RESPONSE [{}]", session->GetPlayerInfo());
1375}
WorldPacket const * Write() override
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendSaveEmblemResult()

void Guild::SendSaveEmblemResult ( WorldSession session,
GuildEmblemError  errCode 
)
static

Definition at line 69 of file Guild.cpp.

70{
72 saveResponse.Error = int32(errCode);
73 session->SendPacket(saveResponse.Write());
74
75 TC_LOG_DEBUG("guild", "Sent SMSG_SAVE_GUILD_EMBLEM [{}] Code: {}", session->GetPlayerInfo(), errCode);
76}
WorldPacket const * Write() override
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetBankTabText()

void Guild::SetBankTabText ( uint8  tabId,
std::string_view  text 
)

Definition at line 2937 of file Guild.cpp.

2938{
2939 if (BankTab* pTab = GetBankTab(tabId))
2940 {
2941 pTab->SetText(text);
2942 pTab->SendText(this, nullptr);
2943
2945 eventPacket.Tab = tabId;
2946 BroadcastPacket(eventPacket.Write());
2947 }
2948}
WorldPacket const * Write() override
+ Here is the call graph for this function:

◆ SetName()

bool Guild::SetName ( std::string_view  name)

Definition at line 1286 of file Guild.cpp.

1287{
1288 if (m_name == name || name.empty() || name.length() > 24 || sObjectMgr->IsReservedName(name) || !ObjectMgr::IsValidCharterName(name))
1289 return false;
1290
1291 m_name = name;
1293 stmt->setString(0, m_name);
1294 stmt->setUInt64(1, GetId());
1295 CharacterDatabase.Execute(stmt);
1296
1298 guildNameChanged.GuildGUID = GetGUID();
1299 guildNameChanged.GuildName = m_name;
1300 BroadcastPacket(guildNameChanged.Write());
1301
1302 return true;
1303}
@ CHAR_UPD_GUILD_NAME
static bool IsValidCharterName(std::string_view name)
Definition: ObjectMgr.cpp:8694
WorldPacket const * Write() override
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SwapItems()

void Guild::SwapItems ( Player player,
uint8  tabId,
uint8  slotId,
uint8  destTabId,
uint8  destSlotId,
uint32  splitedAmount 
)

Definition at line 2909 of file Guild.cpp.

2910{
2911 if (tabId >= _GetPurchasedTabsSize() || slotId >= GUILD_BANK_MAX_SLOTS ||
2912 destTabId >= _GetPurchasedTabsSize() || destSlotId >= GUILD_BANK_MAX_SLOTS)
2913 return;
2914
2915 if (tabId == destTabId && slotId == destSlotId)
2916 return;
2917
2918 BankMoveItemData from(this, player, tabId, slotId);
2919 BankMoveItemData to(this, player, destTabId, destSlotId);
2920 _MoveItems(&from, &to, splitedAmount);
2921}
void _MoveItems(MoveItemData *pSrc, MoveItemData *pDest, uint32 splitedAmount) const
Definition: Guild.cpp:3294
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SwapItemsWithInventory()

void Guild::SwapItemsWithInventory ( Player player,
bool  toChar,
uint8  tabId,
uint8  slotId,
uint8  playerBag,
uint8  playerSlotId,
uint32  splitedAmount 
)

Definition at line 2923 of file Guild.cpp.

2924{
2925 if ((slotId >= GUILD_BANK_MAX_SLOTS && slotId != NULL_SLOT) || tabId >= _GetPurchasedTabsSize())
2926 return;
2927
2928 BankMoveItemData bankData(this, player, tabId, slotId);
2929 PlayerMoveItemData charData(this, player, playerBag, playerSlotId);
2930 if (toChar)
2931 _MoveItems(&bankData, &charData, splitedAmount);
2932 else
2933 _MoveItems(&charData, &bankData, splitedAmount);
2934}
@ NULL_SLOT
Definition: Unit.h:68
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateCriteria()

void Guild::UpdateCriteria ( CriteriaType  type,
uint64  miscValue1,
uint64  miscValue2,
uint64  miscValue3,
WorldObject const *  ref,
Player player 
)

Definition at line 3614 of file Guild.cpp.

3615{
3616 GetAchievementMgr().UpdateCriteria(type, miscValue1, miscValue2, miscValue3, ref, player);
3617}
void UpdateCriteria(CriteriaType type, uint64 miscValue1=0, uint64 miscValue2=0, uint64 miscValue3=0, WorldObject const *ref=nullptr, Player *referencePlayer=nullptr)
+ Here is the call graph for this function:

◆ UpdateMemberData()

void Guild::UpdateMemberData ( Player player,
uint8  dataid,
uint32  value 
)

Definition at line 1253 of file Guild.cpp.

1254{
1255 if (Member* member = GetMember(player->GetGUID()))
1256 {
1257 switch (dataid)
1258 {
1260 member->SetZoneId(value);
1261 break;
1263 member->SetAchievementPoints(value);
1264 break;
1266 member->SetLevel(value);
1267 break;
1268 default:
1269 TC_LOG_ERROR("guild", "Guild::UpdateMemberData: Called with incorrect DATAID {} (value {})", dataid, value);
1270 return;
1271 }
1272 //HandleRoster();
1273 }
1274}
@ GUILD_MEMBER_DATA_LEVEL
Definition: Guild.h:73
@ GUILD_MEMBER_DATA_ACHIEVEMENT_POINTS
Definition: Guild.h:72
@ GUILD_MEMBER_DATA_ZONEID
Definition: Guild.h:71
+ Here is the call graph for this function:

◆ Validate()

bool Guild::Validate ( )

Definition at line 2573 of file Guild.cpp.

2574{
2575 // Validate ranks data
2576 // GUILD RANKS represent a sequence starting from 0 = GUILD_MASTER (ALL PRIVILEGES) to max 9 (lowest privileges).
2577 // The lower rank id is considered higher rank - so promotion does rank-- and demotion does rank++
2578 // Between ranks in sequence cannot be gaps - so 0, 1, 2, 4 is impossible
2579 // Min ranks count is 2 and max is 10.
2580 bool broken_ranks = false;
2581 uint8 ranks = _GetRanksSize();
2582
2583 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
2584 if (ranks < GUILD_RANKS_MIN_COUNT || ranks > GUILD_RANKS_MAX_COUNT)
2585 {
2586 TC_LOG_ERROR("guild", "Guild {} has invalid number of ranks, creating new...", m_id);
2587 broken_ranks = true;
2588 }
2589 else
2590 {
2591 for (uint8 rankId = 0; rankId < ranks; ++rankId)
2592 {
2593 RankInfo* rankInfo = GetRankInfo(GuildRankId(rankId));
2594 if (rankInfo->GetId() != GuildRankId(rankId))
2595 {
2596 TC_LOG_ERROR("guild", "Guild {} has broken rank id {}, creating default set of ranks...", m_id, rankId);
2597 broken_ranks = true;
2598 }
2599 else
2600 rankInfo->CreateMissingTabsIfNeeded(_GetPurchasedTabsSize(), trans, true);
2601 }
2602 }
2603
2604 if (broken_ranks)
2605 {
2606 m_ranks.clear();
2608 }
2609
2610 // Validate members' data
2611 for (auto& [guid, member] : m_members)
2612 if (!GetRankInfo(member.GetRankId()))
2613 member.ChangeRank(trans, _GetLowestRankId());
2614
2615 // Repair the structure of the guild.
2616 // If the guildmaster doesn't exist or isn't member of the guild
2617 // attempt to promote another member.
2618 Member* leader = GetMember(m_leaderGuid);
2619 if (!leader)
2620 {
2621 CharacterDatabaseTransaction dummy(nullptr);
2622 DeleteMember(dummy, m_leaderGuid);
2623 // If no more members left, disband guild
2624 if (m_members.empty())
2625 {
2626 Disband();
2627 return false;
2628 }
2629 }
2630 else if (!leader->IsRank(GuildRankId::GuildMaster))
2631 _SetLeader(trans, *leader);
2632
2633 // Check config if multiple guildmasters are allowed
2634 if (!sConfigMgr->GetBoolDefault("Guild.AllowMultipleGuildMaster", false))
2635 for (auto& [guid, member] : m_members)
2636 if (member.GetRankId() == GuildRankId::GuildMaster && !member.IsSamePlayer(m_leaderGuid))
2637 member.ChangeRank(trans, GetRankInfo(GuildRankOrder(1))->GetId());
2638
2639 if (trans->GetSize() > 0)
2640 CharacterDatabase.CommitTransaction(trans);
2642 return true;
2643}
#define sConfigMgr
Definition: Config.h:61
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_accountsNumber

uint32 Guild::m_accountsNumber
protected

Definition at line 861 of file Guild.h.

◆ m_achievementMgr

std::unique_ptr<GuildAchievementMgr> Guild::m_achievementMgr
protected

Definition at line 872 of file Guild.h.

◆ m_bankEventLog

std::array<LogHolder<BankEventLogEntry>, GUILD_BANK_MAX_TABS + 1> Guild::m_bankEventLog = {}
protected

Definition at line 870 of file Guild.h.

◆ m_bankMoney

uint64 Guild::m_bankMoney
protected

Definition at line 862 of file Guild.h.

◆ m_bankTabs

std::vector<BankTab> Guild::m_bankTabs
protected

Definition at line 866 of file Guild.h.

◆ m_createdDate

time_t Guild::m_createdDate
protected

Definition at line 858 of file Guild.h.

◆ m_emblemInfo

EmblemInfo Guild::m_emblemInfo
protected

Definition at line 860 of file Guild.h.

◆ m_eventLog

LogHolder<EventLogEntry> Guild::m_eventLog
protected

Definition at line 869 of file Guild.h.

◆ m_id

ObjectGuid::LowType Guild::m_id
protected

Definition at line 853 of file Guild.h.

◆ m_info

std::string Guild::m_info
protected

Definition at line 857 of file Guild.h.

◆ m_leaderGuid

ObjectGuid Guild::m_leaderGuid
protected

Definition at line 855 of file Guild.h.

◆ m_members

std::unordered_map<ObjectGuid, Member> Guild::m_members
protected

Definition at line 865 of file Guild.h.

◆ m_motd

std::string Guild::m_motd
protected

Definition at line 856 of file Guild.h.

◆ m_name

std::string Guild::m_name
protected

Definition at line 854 of file Guild.h.

◆ m_newsLog

LogHolder<NewsLogEntry> Guild::m_newsLog
protected

Definition at line 871 of file Guild.h.

◆ m_ranks

std::vector<RankInfo> Guild::m_ranks
protected

Definition at line 864 of file Guild.h.


The documentation for this class was generated from the following files: