AzerothCore 3.3.5a
OpenSource WoW Emulator
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  PlayerMoveItemData
 
class  RankInfo
 

Public Member Functions

const MemberGetMember (ObjectGuid guid) const
 
MemberGetMember (ObjectGuid guid)
 
MemberGetMember (std::string_view name)
 
 Guild ()
 
 ~Guild ()
 
bool Create (Player *pLeader, std::string_view name)
 
void Disband ()
 
uint32 GetId () const
 
ObjectGuid GetLeaderGUID () const
 
std::string const & GetName () const
 
std::string const & GetMOTD () const
 
std::string const & GetInfo () const
 
bool SetName (std::string_view const &name)
 
void HandleRoster (WorldSession *session)
 
void HandleQuery (WorldSession *session)
 
void HandleSetMOTD (WorldSession *session, std::string_view motd)
 
void HandleSetInfo (WorldSession *session, std::string_view info)
 
void HandleSetEmblem (WorldSession *session, const EmblemInfo &emblemInfo)
 
void HandleSetLeader (WorldSession *session, std::string_view name)
 
void HandleSetBankTabInfo (WorldSession *session, uint8 tabId, std::string_view name, std::string_view icon)
 
void HandleSetMemberNote (WorldSession *session, std::string_view name, std::string_view note, bool officer)
 
void HandleSetRankInfo (WorldSession *session, uint8 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 const &name)
 
void HandleAcceptMember (WorldSession *session)
 
void HandleLeaveMember (WorldSession *session)
 
void HandleRemoveMember (WorldSession *session, std::string_view name)
 
void HandleUpdateMemberRank (WorldSession *session, std::string_view name, bool demote)
 
void HandleAddNewRank (WorldSession *session, std::string_view name)
 
void HandleRemoveRank (WorldSession *session, uint8 rankId)
 
void HandleRemoveLowestRank (WorldSession *session)
 
void HandleMemberDepositMoney (WorldSession *session, uint32 amount)
 
bool HandleMemberWithdrawMoney (WorldSession *session, uint32 amount, bool repair=false)
 
void HandleMemberLogout (WorldSession *session)
 
void HandleDisband (WorldSession *session)
 
void UpdateMemberData (Player *player, uint8 dataid, uint32 value)
 
void OnPlayerStatusChange (Player *player, uint32 flag, bool state)
 
void SendInfo (WorldSession *session) const
 
void SendEventLog (WorldSession *session) const
 
void SendBankLog (WorldSession *session, uint8 tabId) const
 
void SendBankTabsInfo (WorldSession *session, bool showTabs=false)
 
void SendBankTabData (WorldSession *session, uint8 tabId, bool sendAllSlots) const
 
void SendBankTabText (WorldSession *session, uint8 tabId) const
 
void SendPermissions (WorldSession *session)
 
void SendMoneyInfo (WorldSession *session) const
 
void SendLoginInfo (WorldSession *session)
 
bool LoadFromDB (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 BroadcastPacketToRank (WorldPacket const *packet, uint8 rankId) const
 
void BroadcastPacket (WorldPacket const *packet) const
 
void MassInviteToEvent (WorldSession *session, uint32 minLevel, uint32 maxLevel, uint32 minRank)
 
template<class Do >
void BroadcastWorker (Do &_do, Player *except=nullptr)
 
bool AddMember (ObjectGuid guid, uint8 rankId=GUILD_RANK_NONE)
 
void DeleteMember (ObjectGuid guid, bool isDisbanding=false, bool isKicked=false, bool canDeleteGuild=false)
 
bool ChangeMemberRank (ObjectGuid guid, uint8 newRank)
 
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)
 
uint64 GetTotalBankMoney () const
 
uint32 GetMemberCount () const
 
time_t GetCreatedDate () const
 
void SetBankTabText (uint8 tabId, std::string_view text)
 
void ResetTimes ()
 
bool ModifyBankMoney (CharacterDatabaseTransaction trans, const uint64 &amount, bool add)
 
uint32 GetMemberSize () const
 

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

uint32 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< uint32, Memberm_members
 
std::vector< BankTabm_bankTabs
 
LogHolder< EventLogEntrym_eventLog
 
std::array< LogHolder< BankEventLogEntry >, GUILD_BANK_MAX_TABS+1 > m_bankEventLog = {}
 

Private Member Functions

uint8 _GetRanksSize () const
 
const RankInfoGetRankInfo (uint8 rankId) const
 
RankInfoGetRankInfo (uint8 rankId)
 
bool _HasRankRight (Player *player, uint32 right) const
 
uint8 _GetLowestRankId () const
 
uint8 _GetPurchasedTabsSize () const
 
BankTabGetBankTab (uint8 tabId)
 
BankTab const * GetBankTab (uint8 tabId) const
 
void _DeleteMemberFromDB (ObjectGuid::LowType lowguid) const
 
void _CreateNewBankTab ()
 
void _CreateDefaultGuildRanks (LocaleConstant loc)
 
bool _CreateRank (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 _SetLeaderGUID (Member &pLeader)
 
void _SetRankBankMoneyPerDay (uint8 rankId, uint32 moneyPerDay)
 
void _SetRankBankTabRightsAndSlots (uint8 rankId, GuildBankRightsAndSlots rightsAndSlots, bool saveToDB=true)
 
int8 _GetRankBankTabRights (uint8 rankId, uint8 tabId) const
 
uint32 _GetRankRights (uint8 rankId) const
 
int32 _GetRankBankMoneyPerDay (uint8 rankId) const
 
int32 _GetRankBankTabSlotsPerDay (uint8 rankId, uint8 tabId) const
 
std::string _GetRankName (uint8 rankId) const
 
int32 _GetMemberRemainingSlots (Member const &member, uint8 tabId) const
 
int32 _GetMemberRemainingMoney (Member const &member) const
 
void _UpdateMemberWithdrawSlots (CharacterDatabaseTransaction trans, ObjectGuid guid, uint8 tabId)
 
bool _MemberHasTabRights (ObjectGuid guid, uint8 tabId, uint32 rights) const
 
void _LogEvent (GuildEventLogTypes eventType, ObjectGuid playerGuid1, ObjectGuid playerGuid2=ObjectGuid::Empty, uint8 newRank=0)
 
void _LogBankEvent (CharacterDatabaseTransaction trans, GuildBankEventLogTypes eventType, uint8 tabId, ObjectGuid playerGuid, uint32 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)
 
bool _DoItemsMove (MoveItemData *pSrc, MoveItemData *pDest, bool sendError, uint32 splitedAmount=0)
 
void _SendBankContent (WorldSession *session, uint8 tabId, bool sendAllSlots) const
 
void _SendBankMoneyUpdate (WorldSession *session) const
 
void _SendBankContentUpdate (MoveItemData *pSrc, MoveItemData *pDest) const
 
void _SendBankContentUpdate (uint8 tabId, SlotIds slots) const
 
void _SendBankList (WorldSession *session=nullptr, uint8 tabId=0, bool sendFullSlots=false, SlotIds *slots=nullptr) const
 
void _BroadcastEvent (GuildEvents guildEvent, ObjectGuid guid=ObjectGuid::Empty, Optional< std::string_view > param1={}, Optional< std::string_view > param2={}, Optional< std::string_view > param3={}) const
 

Detailed Description

Constructor & Destructor Documentation

◆ Guild()

Guild::Guild ( )
1034 :
1035 m_id(0),
1036 m_createdDate(0),
1038 m_bankMoney(0)
1039{
1040}
uint64 m_bankMoney
Definition: Guild.h:795
uint32 m_id
Definition: Guild.h:786
uint32 m_accountsNumber
Definition: Guild.h:794
time_t m_createdDate
Definition: Guild.h:791

◆ ~Guild()

Guild::~Guild ( )
1043{
1044 CharacterDatabaseTransaction temp(nullptr);
1045 _DeleteBankItems(temp);
1046}
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:70
void _DeleteBankItems(CharacterDatabaseTransaction trans, bool removeItemsFromDB=false)
Definition: Guild.cpp:2464

References _DeleteBankItems().

Member Function Documentation

◆ _BroadcastEvent()

void Guild::_BroadcastEvent ( GuildEvents  guildEvent,
ObjectGuid  guid = ObjectGuid::Empty,
Optional< std::string_view >  param1 = {},
Optional< std::string_view >  param2 = {},
Optional< std::string_view >  param3 = {} 
) const
private
2801{
2803 event.Type = guildEvent;
2804 if (param1)
2805 event.Params.push_back(*param1);
2806
2807 if (param2)
2808 {
2809 event.Params.resize(2);
2810 event.Params[1] = *param2;
2811 }
2812
2813 if (param3)
2814 {
2815 event.Params.resize(3);
2816 event.Params[2] = *param3;
2817 }
2818 event.Guid = guid;
2819 BroadcastPacket(event.Write());
2820 LOG_DEBUG("guild", "SMSG_GUILD_EVENT [Broadcast] Event: {}", guildEvent);
2821}
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:168
void BroadcastPacket(WorldPacket const *packet) const
Definition: Guild.cpp:2135
Definition: GuildPackets.h:203
WorldPacket const * Write() override
Definition: GuildPackets.cpp:122
uint8 Type
Definition: GuildPackets.h:209

References BroadcastPacket(), LOG_DEBUG, WorldPackets::Guild::GuildEvent::Type, and WorldPackets::Guild::GuildEvent::Write().

Referenced by AddMember(), DeleteMember(), Disband(), HandleAddNewRank(), HandleBuyBankTab(), HandleLeaveMember(), HandleMemberDepositMoney(), HandleMemberLogout(), HandleMemberWithdrawMoney(), HandleRemoveMember(), HandleRemoveRank(), HandleSetBankTabInfo(), HandleSetLeader(), HandleSetMOTD(), HandleSetRankInfo(), HandleUpdateMemberRank(), ResetTimes(), and SendLoginInfo().

◆ _CreateDefaultGuildRanks()

void Guild::_CreateDefaultGuildRanks ( LocaleConstant  loc)
private
2406{
2408 stmt->SetData(0, m_id);
2409 CharacterDatabase.Execute(stmt);
2410
2411 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_RIGHTS);
2412 stmt->SetData(0, m_id);
2413 CharacterDatabase.Execute(stmt);
2414
2415 _CreateRank(sObjectMgr->GetAcoreString(LANG_GUILD_MASTER, loc), GR_RIGHT_ALL);
2416 _CreateRank(sObjectMgr->GetAcoreString(LANG_GUILD_OFFICER, loc), GR_RIGHT_ALL);
2420}
@ GR_RIGHT_GCHATSPEAK
Definition: Guild.h:81
@ GR_RIGHT_ALL
Definition: Guild.h:97
@ GR_RIGHT_GCHATLISTEN
Definition: Guild.h:80
#define sObjectMgr
Definition: ObjectMgr.h:1623
@ LANG_GUILD_MASTER
Definition: Language.h:748
@ LANG_GUILD_VETERAN
Definition: Language.h:750
@ LANG_GUILD_OFFICER
Definition: Language.h:749
@ LANG_GUILD_INITIATE
Definition: Language.h:752
@ LANG_GUILD_MEMBER
Definition: Language.h:751
@ CHAR_DEL_GUILD_BANK_RIGHTS
Definition: CharacterDatabase.h:157
@ CHAR_DEL_GUILD_RANKS
Definition: CharacterDatabase.h:148
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: PreparedStatement.h:158
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:78
bool _CreateRank(std::string_view name, uint32 rights)
Definition: Guild.cpp:2422

References _CreateRank(), CHAR_DEL_GUILD_BANK_RIGHTS, CHAR_DEL_GUILD_RANKS, CharacterDatabase, GR_RIGHT_ALL, GR_RIGHT_GCHATLISTEN, GR_RIGHT_GCHATSPEAK, LANG_GUILD_INITIATE, LANG_GUILD_MASTER, LANG_GUILD_MEMBER, LANG_GUILD_OFFICER, LANG_GUILD_VETERAN, m_id, PreparedStatementBase::SetData(), and sObjectMgr.

Referenced by Create(), and Validate().

◆ _CreateNewBankTab()

void Guild::_CreateNewBankTab ( )
private
2382{
2383 uint8 tabId = _GetPurchasedTabsSize(); // Next free id
2384 m_bankTabs.emplace_back(m_id, tabId);
2385
2386 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
2387
2389 stmt->SetData(0, m_id);
2390 stmt->SetData (1, tabId);
2391 trans->Append(stmt);
2392
2393 stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD_BANK_TAB);
2394 stmt->SetData(0, m_id);
2395 stmt->SetData (1, tabId);
2396 trans->Append(stmt);
2397
2398 ++tabId;
2399 for (auto& m_rank : m_ranks)
2400 m_rank.CreateMissingTabsIfNeeded(tabId, trans, false);
2401
2402 CharacterDatabase.CommitTransaction(trans);
2403}
std::uint8_t uint8
Definition: Define.h:109
@ CHAR_INS_GUILD_BANK_TAB
Definition: CharacterDatabase.h:150
@ CHAR_DEL_GUILD_BANK_TAB
Definition: CharacterDatabase.h:151
std::vector< BankTab > m_bankTabs
Definition: Guild.h:799
uint8 _GetPurchasedTabsSize() const
Definition: Guild.h:819
std::vector< RankInfo > m_ranks
Definition: Guild.h:797

References _GetPurchasedTabsSize(), CHAR_DEL_GUILD_BANK_TAB, CHAR_INS_GUILD_BANK_TAB, CharacterDatabase, m_bankTabs, m_id, m_ranks, and PreparedStatementBase::SetData().

Referenced by Create(), and HandleBuyBankTab().

◆ _CreateRank()

bool Guild::_CreateRank ( std::string_view  name,
uint32  rights 
)
private
2423{
2424 uint8 newRankId = _GetRanksSize();
2425 if (newRankId >= GUILD_RANKS_MAX_COUNT)
2426 return false;
2427
2428 // Ranks represent sequence 0, 1, 2, ... where 0 means guildmaster
2429 RankInfo info(m_id, newRankId, name, rights, 0);
2430 m_ranks.push_back(info);
2431
2432 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
2433 info.CreateMissingTabsIfNeeded(_GetPurchasedTabsSize(), trans);
2434 info.SaveToDB(trans);
2435 CharacterDatabase.CommitTransaction(trans);
2436
2437 return true;
2438}
@ GUILD_RANKS_MAX_COUNT
Definition: Guild.h:49
uint8 _GetRanksSize() const
Definition: Guild.h:806

References _GetPurchasedTabsSize(), _GetRanksSize(), CharacterDatabase, Guild::RankInfo::CreateMissingTabsIfNeeded(), GUILD_RANKS_MAX_COUNT, m_id, m_ranks, and Guild::RankInfo::SaveToDB().

Referenced by _CreateDefaultGuildRanks(), and HandleAddNewRank().

◆ _DeleteBankItems()

void Guild::_DeleteBankItems ( CharacterDatabaseTransaction  trans,
bool  removeItemsFromDB = false 
)
private
2465{
2466 for (uint8 tabId = 0; tabId < _GetPurchasedTabsSize(); ++tabId)
2467 {
2468 m_bankTabs[tabId].Delete(trans, removeItemsFromDB);
2469 }
2470 m_bankTabs.clear();
2471}

References _GetPurchasedTabsSize(), and m_bankTabs.

Referenced by Disband(), and ~Guild().

◆ _DeleteMemberFromDB()

void Guild::_DeleteMemberFromDB ( ObjectGuid::LowType  lowguid) const
inlineprivate
824 {
826 stmt->SetData(0, lowguid);
827 CharacterDatabase.Execute(stmt);
828 }
@ CHAR_DEL_GUILD_MEMBER
Definition: CharacterDatabase.h:144

References CHAR_DEL_GUILD_MEMBER, CharacterDatabase, and PreparedStatementBase::SetData().

Referenced by DeleteMember(), and LoadMemberFromDB().

◆ _DoItemsMove()

bool Guild::_DoItemsMove ( MoveItemData pSrc,
MoveItemData pDest,
bool  sendError,
uint32  splitedAmount = 0 
)
private
2705{
2706 Item* pDestItem = pDest->GetItem();
2707 bool swap = (pDestItem != nullptr);
2708
2709 Item* pSrcItem = pSrc->GetItem(splitedAmount);
2710 // 1. Can store source item in destination
2711 if (!pDest->CanStore(pSrcItem, swap, sendError))
2712 return false;
2713
2714 // 2. Can store destination item in source
2715 if (swap)
2716 if (!pSrc->CanStore(pDestItem, true, true))
2717 return false;
2718
2719 // GM LOG (TODO: move to scripts)
2720 pDest->LogAction(pSrc);
2721 if (swap)
2722 pSrc->LogAction(pDest);
2723
2724 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
2725 // 3. Log bank events
2726 pDest->LogBankEvent(trans, pSrc, pSrcItem->GetCount());
2727 if (swap)
2728 pSrc->LogBankEvent(trans, pDest, pDestItem->GetCount());
2729
2730 // 4. Remove item from source
2731 pSrc->RemoveItem(trans, pDest, splitedAmount);
2732
2733 // 5. Remove item from destination
2734 if (swap)
2735 pDest->RemoveItem(trans, pSrc);
2736
2737 // 6. Store item in destination
2738 pDest->StoreItem(trans, pSrcItem);
2739
2740 // 7. Store item in source
2741 if (swap)
2742 pSrc->StoreItem(trans, pDestItem);
2743
2744 CharacterDatabase.CommitTransaction(trans);
2745 return true;
2746}
Definition: Item.h:220
uint32 GetCount() const
Definition: Item.h:272

References Guild::MoveItemData::CanStore(), CharacterDatabase, Item::GetCount(), Guild::MoveItemData::GetItem(), Guild::MoveItemData::LogAction(), Guild::MoveItemData::LogBankEvent(), Guild::MoveItemData::RemoveItem(), and Guild::MoveItemData::StoreItem().

Referenced by _MoveItems().

◆ _GetItem()

Item * Guild::_GetItem ( uint8  tabId,
uint8  slotId 
) const
inlineprivate
2639{
2640 if (const BankTab* tab = GetBankTab(tabId))
2641 return tab->GetItem(slotId);
2642 return nullptr;
2643}
BankTab * GetBankTab(uint8 tabId)
Definition: Guild.h:820

References GetBankTab().

◆ _GetLowestRankId()

uint8 Guild::_GetLowestRankId ( ) const
inlineprivate
817{ return uint8(m_ranks.size() - 1); }

References m_ranks.

Referenced by AddMember(), ChangeMemberRank(), HandleRemoveLowestRank(), HandleUpdateMemberRank(), and Validate().

◆ _GetMemberRemainingMoney()

int32 Guild::_GetMemberRemainingMoney ( Member const &  member) const
inlineprivate
2569{
2570 uint8 rankId = member.GetRankId();
2571 if (rankId == GR_GUILDMASTER)
2572 return static_cast<int32>(GUILD_WITHDRAW_MONEY_UNLIMITED);
2573
2575 {
2576 int32 remaining = _GetRankBankMoneyPerDay(rankId) - member.GetBankWithdrawValue(GUILD_BANK_MAX_TABS);
2577 if (remaining > 0)
2578 return remaining;
2579 }
2580 return 0;
2581}
std::int32_t int32
Definition: Define.h:103
@ GUILD_WITHDRAW_MONEY_UNLIMITED
Definition: Guild.h:51
@ GUILD_BANK_MAX_TABS
Definition: Guild.h:45
@ GR_GUILDMASTER
Definition: Guild.h:68
@ GR_RIGHT_WITHDRAW_REPAIR
Definition: Guild.h:94
@ GR_RIGHT_WITHDRAW_GOLD
Definition: Guild.h:95
uint32 _GetRankRights(uint8 rankId) const
Definition: Guild.cpp:2525
int32 _GetRankBankMoneyPerDay(uint8 rankId) const
Definition: Guild.cpp:2532

References _GetRankBankMoneyPerDay(), _GetRankRights(), Guild::Member::GetBankWithdrawValue(), Guild::Member::GetRankId(), GR_GUILDMASTER, GR_RIGHT_WITHDRAW_GOLD, GR_RIGHT_WITHDRAW_REPAIR, GUILD_BANK_MAX_TABS, and GUILD_WITHDRAW_MONEY_UNLIMITED.

Referenced by HandleMemberWithdrawMoney(), and SendMoneyInfo().

◆ _GetMemberRemainingSlots()

int32 Guild::_GetMemberRemainingSlots ( Member const &  member,
uint8  tabId 
) const
inlineprivate
2555{
2556 uint8 rankId = member.GetRankId();
2557 if (rankId == GR_GUILDMASTER)
2558 return static_cast<int32>(GUILD_WITHDRAW_SLOT_UNLIMITED);
2559 if ((_GetRankBankTabRights(rankId, tabId) & GUILD_BANK_RIGHT_VIEW_TAB) != 0)
2560 {
2561 int32 remaining = _GetRankBankTabSlotsPerDay(rankId, tabId) - member.GetBankWithdrawValue(tabId);
2562 if (remaining > 0)
2563 return remaining;
2564 }
2565 return 0;
2566}
@ GUILD_WITHDRAW_SLOT_UNLIMITED
Definition: Guild.h:52
@ GUILD_BANK_RIGHT_VIEW_TAB
Definition: Guild.h:190
int8 _GetRankBankTabRights(uint8 rankId, uint8 tabId) const
Definition: Guild.cpp:2547
int32 _GetRankBankTabSlotsPerDay(uint8 rankId, uint8 tabId) const
Definition: Guild.cpp:2539

References _GetRankBankTabRights(), _GetRankBankTabSlotsPerDay(), Guild::Member::GetBankWithdrawValue(), Guild::Member::GetRankId(), GR_GUILDMASTER, GUILD_BANK_RIGHT_VIEW_TAB, and GUILD_WITHDRAW_SLOT_UNLIMITED.

Referenced by _SendBankList(), and SendPermissions().

◆ _GetPurchasedTabsSize()

◆ _GetRankBankMoneyPerDay()

int32 Guild::_GetRankBankMoneyPerDay ( uint8  rankId) const
inlineprivate
2533{
2534 if (const RankInfo* rankInfo = GetRankInfo(rankId))
2535 return rankInfo->GetBankMoneyPerDay();
2536 return 0;
2537}
const RankInfo * GetRankInfo(uint8 rankId) const
Definition: Guild.h:807

References GetRankInfo().

Referenced by _GetMemberRemainingMoney(), and SendPermissions().

◆ _GetRankBankTabRights()

int8 Guild::_GetRankBankTabRights ( uint8  rankId,
uint8  tabId 
) const
inlineprivate
2548{
2549 if (const RankInfo* rankInfo = GetRankInfo(rankId))
2550 return rankInfo->GetBankTabRights(tabId);
2551 return 0;
2552}

References GetRankInfo().

Referenced by _GetMemberRemainingSlots(), _MemberHasTabRights(), and SendPermissions().

◆ _GetRankBankTabSlotsPerDay()

int32 Guild::_GetRankBankTabSlotsPerDay ( uint8  rankId,
uint8  tabId 
) const
inlineprivate
2540{
2541 if (tabId < _GetPurchasedTabsSize())
2542 if (const RankInfo* rankInfo = GetRankInfo(rankId))
2543 return rankInfo->GetBankTabSlotsPerDay(tabId);
2544 return 0;
2545}

References _GetPurchasedTabsSize(), and GetRankInfo().

Referenced by _GetMemberRemainingSlots(), and _UpdateMemberWithdrawSlots().

◆ _GetRankName()

std::string Guild::_GetRankName ( uint8  rankId) const
inlineprivate
2519{
2520 if (const RankInfo* rankInfo = GetRankInfo(rankId))
2521 return rankInfo->GetName();
2522 return "<unknown>";
2523}

References GetRankInfo().

Referenced by HandleUpdateMemberRank().

◆ _GetRankRights()

uint32 Guild::_GetRankRights ( uint8  rankId) const
inlineprivate
2526{
2527 if (const RankInfo* rankInfo = GetRankInfo(rankId))
2528 return rankInfo->GetRights();
2529 return 0;
2530}

References GetRankInfo().

Referenced by _GetMemberRemainingMoney(), _HasRankRight(), HandleMemberWithdrawMoney(), and SendPermissions().

◆ _GetRanksSize()

uint8 Guild::_GetRanksSize ( ) const
inlineprivate

◆ _HasRankRight()

bool Guild::_HasRankRight ( Player player,
uint32  right 
) const
inlineprivate
810 {
811 if (player)
812 if (Member const* member = GetMember(player->GetGUID()))
813 return (_GetRankRights(member->GetRankId()) & right) != GR_RIGHT_EMPTY;
814 return false;
815 }
@ GR_RIGHT_EMPTY
Definition: Guild.h:79
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:109
const Member * GetMember(ObjectGuid guid) const
Definition: Guild.h:384

References _GetRankRights(), Object::GetGUID(), GetMember(), and GR_RIGHT_EMPTY.

Referenced by BroadcastToGuild(), HandleInviteMember(), HandleRemoveMember(), HandleRoster(), HandleSetInfo(), HandleSetMemberNote(), HandleSetMOTD(), and HandleUpdateMemberRank().

◆ _IsLeader()

bool Guild::_IsLeader ( Player player) const
private
2456{
2457 if (player->GetGUID() == m_leaderGuid)
2458 return true;
2459 if (const Member* member = GetMember(player->GetGUID()))
2460 return member->IsRank(GR_GUILDMASTER);
2461 return false;
2462}
ObjectGuid m_leaderGuid
Definition: Guild.h:788

References Object::GetGUID(), GetMember(), GR_GUILDMASTER, and m_leaderGuid.

Referenced by HandleAddNewRank(), HandleDisband(), HandleLeaveMember(), HandleRemoveRank(), HandleSetEmblem(), HandleSetLeader(), and HandleSetRankInfo().

◆ _LogBankEvent()

void Guild::_LogBankEvent ( CharacterDatabaseTransaction  trans,
GuildBankEventLogTypes  eventType,
uint8  tabId,
ObjectGuid  playerGuid,
uint32  itemOrMoney,
uint16  itemStackCount = 0,
uint8  destTabId = 0 
)
private
2618{
2619 if (tabId > GUILD_BANK_MAX_TABS)
2620 return;
2621
2622 // not logging moves within the same tab
2623 if (eventType == GUILD_BANK_LOG_MOVE_ITEM && tabId == destTabId)
2624 return;
2625
2626 uint8 dbTabId = tabId;
2627 if (BankEventLogEntry::IsMoneyEvent(eventType))
2628 {
2629 tabId = GUILD_BANK_MAX_TABS;
2630 dbTabId = GUILD_BANK_MONEY_LOGS_TAB;
2631 }
2632 LogHolder<BankEventLogEntry>& pLog = m_bankEventLog[tabId];
2633 pLog.AddEvent(trans, m_id, pLog.GetNextGUID(), eventType, dbTabId, guid, itemOrMoney, itemStackCount, destTabId);
2634
2635 sScriptMgr->OnGuildBankEvent(this, uint8(eventType), tabId, guid.GetCounter(), itemOrMoney, itemStackCount, destTabId);
2636}
#define sScriptMgr
Definition: ScriptMgr.h:708
@ GUILD_BANK_MONEY_LOGS_TAB
Definition: Guild.h:47
@ GUILD_BANK_LOG_MOVE_ITEM
Definition: Guild.h:202
std::array< LogHolder< BankEventLogEntry >, GUILD_BANK_MAX_TABS+1 > m_bankEventLog
Definition: Guild.h:803
bool IsMoneyEvent() const
Definition: Guild.h:457

References Guild::LogHolder< Entry >::AddEvent(), ObjectGuid::GetCounter(), Guild::LogHolder< Entry >::GetNextGUID(), GUILD_BANK_LOG_MOVE_ITEM, GUILD_BANK_MAX_TABS, GUILD_BANK_MONEY_LOGS_TAB, Guild::BankEventLogEntry::IsMoneyEvent(), m_bankEventLog, m_id, and sScriptMgr.

Referenced by HandleMemberDepositMoney(), and HandleMemberWithdrawMoney().

◆ _LogEvent()

void Guild::_LogEvent ( GuildEventLogTypes  eventType,
ObjectGuid  playerGuid1,
ObjectGuid  playerGuid2 = ObjectGuid::Empty,
uint8  newRank = 0 
)
inlineprivate
2608{
2609 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
2610 m_eventLog.AddEvent(trans, m_id, m_eventLog.GetNextGUID(), eventType, playerGuid1, playerGuid2, newRank);
2611 CharacterDatabase.CommitTransaction(trans);
2612
2613 sScriptMgr->OnGuildEvent(this, uint8(eventType), playerGuid1.GetCounter(), playerGuid2.GetCounter(), newRank);
2614}
LowType GetCounter() const
Definition: ObjectGuid.h:145
LogHolder< EventLogEntry > m_eventLog
Definition: Guild.h:802

References CharacterDatabase, ObjectGuid::GetCounter(), m_eventLog, m_id, and sScriptMgr.

Referenced by AddMember(), HandleInviteMember(), HandleLeaveMember(), HandleRemoveMember(), and HandleUpdateMemberRank().

◆ _MemberHasTabRights()

bool Guild::_MemberHasTabRights ( ObjectGuid  guid,
uint8  tabId,
uint32  rights 
) const
inlineprivate
2595{
2596 if (const Member* member = GetMember(guid))
2597 {
2598 // Leader always has full rights
2599 if (member->IsRank(GR_GUILDMASTER) || m_leaderGuid == guid)
2600 return true;
2601 return (_GetRankBankTabRights(member->GetRankId(), tabId) & rights) == rights;
2602 }
2603 return false;
2604}

References _GetRankBankTabRights(), GetMember(), GR_GUILDMASTER, and m_leaderGuid.

Referenced by _SendBankContent(), and _SendBankList().

◆ _ModifyBankMoney()

bool Guild::_ModifyBankMoney ( CharacterDatabaseTransaction  trans,
uint64  amount,
bool  add 
)
private
2474{
2475 if (add)
2476 m_bankMoney += amount;
2477 else
2478 {
2479 // Check if there is enough money in bank.
2480 if (m_bankMoney < amount)
2481 return false;
2482 m_bankMoney -= amount;
2483 }
2484
2486 stmt->SetData(0, m_bankMoney);
2487 stmt->SetData(1, m_id);
2488 trans->Append(stmt);
2489 return true;
2490}
@ CHAR_UPD_GUILD_BANK_MONEY
Definition: CharacterDatabase.h:175

References CHAR_UPD_GUILD_BANK_MONEY, CharacterDatabase, m_bankMoney, m_id, and PreparedStatementBase::SetData().

Referenced by HandleMemberDepositMoney(), HandleMemberWithdrawMoney(), and ModifyBankMoney().

◆ _MoveItems()

void Guild::_MoveItems ( MoveItemData pSrc,
MoveItemData pDest,
uint32  splitedAmount 
)
private
2652{
2653 // 1. Initialize source item
2654 if (!pSrc->InitItem())
2655 return; // No source item
2656
2657 // 2. Check source item
2658 if (!pSrc->CheckItem(splitedAmount))
2659 return; // Source item or splited amount is invalid
2660
2661 // 3. Check destination rights
2662 if (!pDest->HasStoreRights(pSrc))
2663 return; // Player has no rights to store item in destination
2664
2665 // 4. Check source withdraw rights
2666 if (!pSrc->HasWithdrawRights(pDest))
2667 return; // Player has no rights to withdraw items from source
2668
2669 // 5. Check split
2670 if (splitedAmount)
2671 {
2672 // 5.1. Clone source item
2673 if (!pSrc->CloneItem(splitedAmount))
2674 return; // Item could not be cloned
2675
2676 // 5.2. Move splited item to destination
2677 _DoItemsMove(pSrc, pDest, true, splitedAmount);
2678 }
2679 else // 6. No split
2680 {
2681 // 6.1. Try to merge items in destination (pDest->GetItem() == nullptr)
2682 if (!_DoItemsMove(pSrc, pDest, false)) // Item could not be merged
2683 {
2684 // 6.2. Try to swap items
2685 // 6.2.1. Initialize destination item
2686 if (!pDest->InitItem())
2687 return;
2688
2689 // 6.2.2. Check rights to store item in source (opposite direction)
2690 if (!pSrc->HasStoreRights(pDest))
2691 return; // Player has no rights to store item in source (opposite direction)
2692
2693 if (!pDest->HasWithdrawRights(pSrc))
2694 return; // Player has no rights to withdraw item from destination (opposite direction)
2695
2696 // 6.2.3. Swap items (pDest->GetItem() != nullptr)
2697 _DoItemsMove(pSrc, pDest, true);
2698 }
2699 }
2700 // 7. Send changes
2701 _SendBankContentUpdate(pSrc, pDest);
2702}
bool _DoItemsMove(MoveItemData *pSrc, MoveItemData *pDest, bool sendError, uint32 splitedAmount=0)
Definition: Guild.cpp:2704
void _SendBankContentUpdate(MoveItemData *pSrc, MoveItemData *pDest) const
Definition: Guild.cpp:2762

References _DoItemsMove(), _SendBankContentUpdate(), Guild::MoveItemData::CheckItem(), Guild::MoveItemData::CloneItem(), Guild::MoveItemData::HasStoreRights(), Guild::MoveItemData::HasWithdrawRights(), and Guild::MoveItemData::InitItem().

Referenced by SwapItems(), and SwapItemsWithInventory().

◆ _RemoveItem()

void Guild::_RemoveItem ( CharacterDatabaseTransaction  trans,
uint8  tabId,
uint8  slotId 
)
inlineprivate
2646{
2647 if (BankTab* pTab = GetBankTab(tabId))
2648 pTab->SetItem(trans, slotId, nullptr);
2649}

References GetBankTab().

◆ _SendBankContent()

void Guild::_SendBankContent ( WorldSession session,
uint8  tabId,
bool  sendAllSlots 
) const
private
2749{
2750 ObjectGuid guid = session->GetPlayer()->GetGUID();
2752 return;
2753
2754 _SendBankList(session, tabId, sendAllSlots);
2755}
Definition: ObjectGuid.h:118
void _SendBankList(WorldSession *session=nullptr, uint8 tabId=0, bool sendFullSlots=false, SlotIds *slots=nullptr) const
Definition: Guild.cpp:2823
bool _MemberHasTabRights(ObjectGuid guid, uint8 tabId, uint32 rights) const
Definition: Guild.cpp:2594
Player * GetPlayer() const
Definition: WorldSession.h:362

References _MemberHasTabRights(), _SendBankList(), Object::GetGUID(), WorldSession::GetPlayer(), and GUILD_BANK_RIGHT_VIEW_TAB.

Referenced by SendBankTabData().

◆ _SendBankContentUpdate() [1/2]

void Guild::_SendBankContentUpdate ( MoveItemData pSrc,
MoveItemData pDest 
) const
private
2763{
2764 ASSERT(pSrc->IsBank() || pDest->IsBank());
2765
2766 uint8 tabId = 0;
2767 SlotIds slots;
2768 if (pSrc->IsBank()) // B ->
2769 {
2770 tabId = pSrc->GetContainer();
2771 slots.insert(pSrc->GetSlotId());
2772 if (pDest->IsBank()) // B -> B
2773 {
2774 // Same tab - add destination slots to collection
2775 if (pDest->GetContainer() == pSrc->GetContainer())
2776 pDest->CopySlots(slots);
2777 else // Different tabs - send second message
2778 {
2779 SlotIds destSlots;
2780 pDest->CopySlots(destSlots);
2781 _SendBankContentUpdate(pDest->GetContainer(), destSlots);
2782 }
2783 }
2784 }
2785 else if (pDest->IsBank()) // C -> B
2786 {
2787 tabId = pDest->GetContainer();
2788 pDest->CopySlots(slots);
2789 }
2790
2791 _SendBankContentUpdate(tabId, slots);
2792}
#define ASSERT
Definition: Errors.h:68
std::set< uint8 > SlotIds
Definition: Guild.h:292

References _SendBankContentUpdate(), ASSERT, Guild::MoveItemData::CopySlots(), Guild::MoveItemData::GetContainer(), Guild::MoveItemData::GetSlotId(), and Guild::MoveItemData::IsBank().

Referenced by _MoveItems(), and _SendBankContentUpdate().

◆ _SendBankContentUpdate() [2/2]

void Guild::_SendBankContentUpdate ( uint8  tabId,
SlotIds  slots 
) const
private
2795{
2796 _SendBankList(nullptr, tabId, false, &slots);
2797}

References _SendBankList().

◆ _SendBankList()

void Guild::_SendBankList ( WorldSession session = nullptr,
uint8  tabId = 0,
bool  sendFullSlots = false,
SlotIds slots = nullptr 
) const
private
2824{
2825 if (!sScriptMgr->CanGuildSendBankList(this, session, tabId, sendAllSlots))
2826 return;
2827
2829
2830 packet.Money = m_bankMoney;
2831 packet.Tab = int32(tabId);
2832 packet.FullUpdate = sendAllSlots;
2833
2834 if (sendAllSlots && !tabId)
2835 {
2836 packet.TabInfo.reserve(_GetPurchasedTabsSize());
2837 for (uint8 i = 0; i < _GetPurchasedTabsSize(); ++i)
2838 {
2840 tabInfo.Name = m_bankTabs[i].GetName();
2841 tabInfo.Icon = m_bankTabs[i].GetIcon();
2842 packet.TabInfo.push_back(tabInfo);
2843 }
2844 }
2845
2846 if (BankTab const* tab = GetBankTab(tabId))
2847 {
2848 auto fillItems = [&](auto begin, auto end, bool skipEmpty)
2849 {
2850 for (auto itr = begin; itr != end; ++itr)
2851 {
2852 if (Item* tabItem = tab->GetItem(*itr))
2853 {
2855
2856 itemInfo.Slot = *itr;
2857 itemInfo.ItemID = tabItem->GetEntry();
2858 itemInfo.Count = int32(tabItem->GetCount());
2859 itemInfo.Charges = int32(std::abs(tabItem->GetSpellCharges()));
2860 itemInfo.EnchantmentID = int32(tabItem->GetEnchantmentId(PERM_ENCHANTMENT_SLOT));
2861 itemInfo.Flags = tabItem->GetInt32Value(ITEM_FIELD_FLAGS);
2862 itemInfo.RandomPropertiesID = tabItem->GetItemRandomPropertyId();
2863 itemInfo.RandomPropertiesSeed = int32(tabItem->GetItemSuffixFactor());
2864
2865 for (uint32 socketSlot = 0; socketSlot < MAX_GEM_SOCKETS; ++socketSlot)
2866 {
2867 if (uint32 enchId = tabItem->GetEnchantmentId(EnchantmentSlot(SOCK_ENCHANTMENT_SLOT + socketSlot)))
2868 {
2870 gem.SocketIndex = socketSlot;
2871 gem.SocketEnchantID = int32(enchId);
2872 itemInfo.SocketEnchant.push_back(gem);
2873 }
2874 }
2875
2876 packet.ItemInfo.push_back(itemInfo);
2877 }
2878 else if (!skipEmpty)
2879 {
2881
2882 itemInfo.Slot = *itr;
2883 itemInfo.ItemID = 0;
2884
2885 packet.ItemInfo.push_back(itemInfo);
2886 }
2887 }
2888
2889 };
2890
2891 if (sendAllSlots)
2892 fillItems(boost::make_counting_iterator(uint8(0)), boost::make_counting_iterator(uint8(GUILD_BANK_MAX_SLOTS)), true);
2893 else if (slots && !slots->empty())
2894 fillItems(slots->begin(), slots->end(), false);
2895 }
2896
2897 if (session)
2898 {
2899 if (Member const* member = GetMember(session->GetPlayer()->GetGUID()))
2900 packet.WithdrawalsRemaining = _GetMemberRemainingSlots(*member, tabId);
2901
2902 session->SendPacket(packet.Write());
2903 LOG_DEBUG("guild", "SMSG_GUILD_BANK_LIST [{}]: TabId: {}, FullSlots: {}, slots: {}",
2904 session->GetPlayerInfo(), tabId, sendAllSlots, packet.WithdrawalsRemaining);
2905 }
2906 else
2907 {
2908 packet.Write();
2909 for (auto const& [guid, member] : m_members)
2910 {
2911 if (!member.ShouldReceiveBankPartialUpdatePackets())
2912 continue;
2913
2914 if (!_MemberHasTabRights(member.GetGUID(), tabId, GUILD_BANK_RIGHT_VIEW_TAB))
2915 continue;
2916
2917 Player* player = member.FindPlayer();
2918 if (!player)
2919 continue;
2920
2922 player->SendDirectMessage(packet.GetRawPacket());
2923 LOG_DEBUG("guild", "SMSG_GUILD_BANK_LIST [{}]: TabId: {}, FullSlots: {}, slots: {}"
2924 , player->GetName(), tabId, sendAllSlots, packet.WithdrawalsRemaining);
2925 }
2926 }
2927}
std::uint32_t uint32
Definition: Define.h:107
@ GUILD_BANK_MAX_SLOTS
Definition: Guild.h:46
@ ITEM_FIELD_FLAGS
Definition: UpdateFields.h:42
#define MAX_GEM_SOCKETS
Definition: Item.h:188
EnchantmentSlot
Definition: Item.h:168
@ PERM_ENCHANTMENT_SLOT
Definition: Item.h:169
@ SOCK_ENCHANTMENT_SLOT
Definition: Item.h:171
std::string const & GetName() const
Definition: Object.h:458
Definition: Player.h:1064
void SendDirectMessage(WorldPacket const *data) const
Definition: Player.cpp:5692
int32 _GetMemberRemainingSlots(Member const &member, uint8 tabId) const
Definition: Guild.cpp:2554
std::unordered_map< uint32, Member > m_members
Definition: Guild.h:798
WorldPacket const * GetRawPacket() const
Definition: Packet.h:38
Definition: GuildPackets.h:457
uint8 SocketIndex
Definition: GuildPackets.h:458
int32 SocketEnchantID
Definition: GuildPackets.h:459
Definition: GuildPackets.h:463
int32 EnchantmentID
Definition: GuildPackets.h:469
int32 Flags
Definition: GuildPackets.h:471
std::vector< GuildBankSocketEnchant > SocketEnchant
Definition: GuildPackets.h:472
uint32 ItemID
Definition: GuildPackets.h:464
int32 Count
Definition: GuildPackets.h:468
int32 RandomPropertiesID
Definition: GuildPackets.h:466
int32 Charges
Definition: GuildPackets.h:470
int32 RandomPropertiesSeed
Definition: GuildPackets.h:465
uint8 Slot
Definition: GuildPackets.h:467
Definition: GuildPackets.h:476
std::string Name
Definition: GuildPackets.h:477
std::string Icon
Definition: GuildPackets.h:478
Definition: GuildPackets.h:482
int32 WithdrawalsRemaining
Definition: GuildPackets.h:490
bool FullUpdate
Definition: GuildPackets.h:493
WorldPacket const * Write() override
Definition: GuildPackets.cpp:285
void SetWithdrawalsRemaining(int32 withdrawalsRemaining)
Definition: GuildPackets.cpp:331
uint8 Tab
Definition: GuildPackets.h:491
std::vector< GuildBankTabInfo > TabInfo
Definition: GuildPackets.h:489
uint64 Money
Definition: GuildPackets.h:492
std::vector< GuildBankItemInfo > ItemInfo
Definition: GuildPackets.h:488
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
Definition: WorldSession.cpp:214
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:191

References _GetMemberRemainingSlots(), _GetPurchasedTabsSize(), _MemberHasTabRights(), WorldPackets::Guild::GuildBankItemInfo::Charges, WorldPackets::Guild::GuildBankItemInfo::Count, WorldPackets::Guild::GuildBankItemInfo::EnchantmentID, WorldPackets::Guild::GuildBankItemInfo::Flags, WorldPackets::Guild::GuildBankQueryResults::FullUpdate, GetBankTab(), Object::GetGUID(), GetMember(), WorldObject::GetName(), WorldSession::GetPlayer(), WorldSession::GetPlayerInfo(), WorldPackets::Packet::GetRawPacket(), GUILD_BANK_MAX_SLOTS, GUILD_BANK_RIGHT_VIEW_TAB, WorldPackets::Guild::GuildBankTabInfo::Icon, ITEM_FIELD_FLAGS, WorldPackets::Guild::GuildBankItemInfo::ItemID, WorldPackets::Guild::GuildBankQueryResults::ItemInfo, LOG_DEBUG, m_bankMoney, m_bankTabs, m_members, MAX_GEM_SOCKETS, WorldPackets::Guild::GuildBankQueryResults::Money, WorldPackets::Guild::GuildBankTabInfo::Name, PERM_ENCHANTMENT_SLOT, WorldPackets::Guild::GuildBankItemInfo::RandomPropertiesID, WorldPackets::Guild::GuildBankItemInfo::RandomPropertiesSeed, Player::SendDirectMessage(), WorldSession::SendPacket(), WorldPackets::Guild::GuildBankQueryResults::SetWithdrawalsRemaining(), WorldPackets::Guild::GuildBankItemInfo::Slot, SOCK_ENCHANTMENT_SLOT, WorldPackets::Guild::GuildBankItemInfo::SocketEnchant, WorldPackets::Guild::GuildBankSocketEnchant::SocketEnchantID, WorldPackets::Guild::GuildBankSocketEnchant::SocketIndex, sScriptMgr, WorldPackets::Guild::GuildBankQueryResults::Tab, WorldPackets::Guild::GuildBankQueryResults::TabInfo, WorldPackets::Guild::GuildBankQueryResults::WithdrawalsRemaining, and WorldPackets::Guild::GuildBankQueryResults::Write().

Referenced by _SendBankContent(), _SendBankContentUpdate(), _SendBankMoneyUpdate(), and SendBankTabsInfo().

◆ _SendBankMoneyUpdate()

void Guild::_SendBankMoneyUpdate ( WorldSession session) const
private
2758{
2759 _SendBankList(session);
2760}

References _SendBankList().

◆ _SetLeaderGUID()

void Guild::_SetLeaderGUID ( Member pLeader)
private
2493{
2494 m_leaderGuid = pLeader.GetGUID();
2495 pLeader.ChangeRank(GR_GUILDMASTER);
2496
2498 stmt->SetData(0, m_leaderGuid.GetCounter());
2499 stmt->SetData(1, m_id);
2500 CharacterDatabase.Execute(stmt);
2501}
@ CHAR_UPD_GUILD_LEADER
Definition: CharacterDatabase.h:170

References Guild::Member::ChangeRank(), CHAR_UPD_GUILD_LEADER, CharacterDatabase, ObjectGuid::GetCounter(), Guild::Member::GetGUID(), GR_GUILDMASTER, m_id, m_leaderGuid, and PreparedStatementBase::SetData().

Referenced by DeleteMember(), HandleSetLeader(), and Validate().

◆ _SetRankBankMoneyPerDay()

void Guild::_SetRankBankMoneyPerDay ( uint8  rankId,
uint32  moneyPerDay 
)
private
2504{
2505 if (RankInfo* rankInfo = GetRankInfo(rankId))
2506 rankInfo->SetBankMoneyPerDay(moneyPerDay);
2507}

References GetRankInfo().

Referenced by HandleSetRankInfo().

◆ _SetRankBankTabRightsAndSlots()

void Guild::_SetRankBankTabRightsAndSlots ( uint8  rankId,
GuildBankRightsAndSlots  rightsAndSlots,
bool  saveToDB = true 
)
private
2510{
2511 if (rightsAndSlots.GetTabId() >= _GetPurchasedTabsSize())
2512 return;
2513
2514 if (RankInfo* rankInfo = GetRankInfo(rankId))
2515 rankInfo->SetBankTabSlotsAndRights(rightsAndSlots, saveToDB);
2516}
uint8 GetTabId() const
Definition: Guild.h:282

References _GetPurchasedTabsSize(), GetRankInfo(), and GuildBankRightsAndSlots::GetTabId().

Referenced by HandleSetRankInfo(), and LoadBankRightFromDB().

◆ _UpdateAccountsNumber()

void Guild::_UpdateAccountsNumber ( )
private
2443{
2444 // We use a set to be sure each element will be unique
2445 std::unordered_set<uint32> accountsIdSet;
2446 for (auto const& [guid, member] : m_members)
2447 accountsIdSet.insert(member.GetAccountId());
2448
2449 m_accountsNumber = accountsIdSet.size();
2450}

References m_accountsNumber, and m_members.

Referenced by AddMember(), DeleteMember(), and Validate().

◆ _UpdateMemberWithdrawSlots()

void Guild::_UpdateMemberWithdrawSlots ( CharacterDatabaseTransaction  trans,
ObjectGuid  guid,
uint8  tabId 
)
inlineprivate
2584{
2585 if (Member* member = GetMember(guid))
2586 {
2587 uint8 rankId = member->GetRankId();
2588 if (rankId != GR_GUILDMASTER
2589 && member->GetBankWithdrawValue(tabId) < _GetRankBankTabSlotsPerDay(rankId, tabId))
2590 member->UpdateBankWithdrawValue(trans, tabId, 1);
2591 }
2592}

References _GetRankBankTabSlotsPerDay(), GetMember(), and GR_GUILDMASTER.

◆ AddMember()

bool Guild::AddMember ( ObjectGuid  guid,
uint8  rankId = GUILD_RANK_NONE 
)
2176{
2178 // Player cannot be in guild
2179 if (player)
2180 {
2181 if (player->GetGuildId() != 0)
2182 return false;
2183 }
2184 else if (sCharacterCache->GetCharacterGuildIdByGuid(guid) != 0)
2185 return false;
2186
2187 // Remove all player signs from another petitions
2188 // This will be prevent attempt to join many guilds and corrupt guild data integrity
2190
2191 ObjectGuid::LowType lowguid = guid.GetCounter();
2192
2193 // If rank was not passed, assign lowest possible rank
2194 if (rankId == GUILD_RANK_NONE)
2195 rankId = _GetLowestRankId();
2196
2197 auto [memberIt, isNew] = m_members.try_emplace(lowguid, m_id, guid, rankId);
2198 if (!isNew)
2199 {
2200 LOG_ERROR("guild", "Tried to add {} to guild '{}'. Member already exists.", guid.ToString(), m_name);
2201 return false;
2202 }
2203
2204 Member& member = memberIt->second;
2205 std::string name;
2206 if (player)
2207 {
2208 player->SetInGuild(m_id);
2209 player->SetGuildIdInvited(0);
2210 player->SetRank(rankId);
2211 member.SetStats(player);
2212 SendLoginInfo(player->GetSession());
2213 name = player->GetName();
2214 }
2215 else
2216 {
2217 member.ResetFlags();
2218
2219 bool ok = false;
2220 // xinef: sync query
2221 // Player must exist
2223 stmt->SetData(0, guid.GetCounter());
2224 if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
2225 {
2226 Field* fields = result->Fetch();
2227 name = fields[0].Get<std::string>();
2228 member.SetStats(
2229 name,
2230 fields[1].Get<uint8>(),
2231 fields[2].Get<uint8>(),
2232 fields[3].Get<uint8>(),
2233 fields[4].Get<uint16>(),
2234 fields[5].Get<uint32>());
2235
2236 ok = member.CheckStats();
2237 }
2238 if (!ok)
2239 {
2240 m_members.erase(memberIt);
2241 return false;
2242 }
2243 sCharacterCache->UpdateCharacterGuildId(guid, m_id);
2244 }
2245
2246 CharacterDatabaseTransaction trans(nullptr);
2247 member.SaveToDB(trans);
2248
2251 _BroadcastEvent(GE_JOINED, guid, name);
2252
2253 // Call scripts if member was succesfully added (and stored to database)
2254 sScriptMgr->OnGuildAddMember(this, player, rankId);
2255
2256 return true;
2257}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:156
std::uint16_t uint16
Definition: Define.h:108
@ GE_JOINED
Definition: Guild.h:153
@ GUILD_RANK_NONE
Definition: Guild.h:50
@ GUILD_EVENT_LOG_JOIN_GUILD
Definition: Guild.h:214
#define sCharacterCache
Definition: CharacterCache.h:83
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: DatabaseEnvFwd.h:46
@ CHAR_SEL_CHAR_DATA_FOR_GUILD
Definition: CharacterDatabase.h:181
@ GUILD_CHARTER_TYPE
Definition: WorldSession.h:222
Player * FindConnectedPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:260
Class used to access individual fields of database query result.
Definition: Field.h:99
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:113
std::string ToString() const
Definition: ObjectGuid.cpp:47
uint32 LowType
Definition: ObjectGuid.h:122
void SetGuildIdInvited(uint32 GuildId)
Definition: Player.h:1880
uint32 GetGuildId() const
Definition: Player.h:1881
WorldSession * GetSession() const
Definition: Player.h:1978
void SetInGuild(uint32 GuildId)
Definition: Player.h:1872
void SetRank(uint8 rankId)
Definition: Player.h:1878
static void RemovePetitionsAndSigns(ObjectGuid guid, uint32 type)
Definition: Player.cpp:10108
void SendLoginInfo(WorldSession *session)
Definition: Guild.cpp:1878
std::string m_name
Definition: Guild.h:787
void _UpdateAccountsNumber()
Definition: Guild.cpp:2442
void _BroadcastEvent(GuildEvents guildEvent, ObjectGuid guid=ObjectGuid::Empty, Optional< std::string_view > param1={}, Optional< std::string_view > param2={}, Optional< std::string_view > param3={}) const
Definition: Guild.cpp:2799
void _LogEvent(GuildEventLogTypes eventType, ObjectGuid playerGuid1, ObjectGuid playerGuid2=ObjectGuid::Empty, uint8 newRank=0)
Definition: Guild.cpp:2607
uint8 _GetLowestRankId() const
Definition: Guild.h:817

References _BroadcastEvent(), _GetLowestRankId(), _LogEvent(), _UpdateAccountsNumber(), CHAR_SEL_CHAR_DATA_FOR_GUILD, CharacterDatabase, Guild::Member::CheckStats(), ObjectAccessor::FindConnectedPlayer(), GE_JOINED, Field::Get(), ObjectGuid::GetCounter(), Player::GetGuildId(), WorldObject::GetName(), Player::GetSession(), GUILD_CHARTER_TYPE, GUILD_EVENT_LOG_JOIN_GUILD, GUILD_RANK_NONE, LOG_ERROR, m_id, m_members, m_name, Player::RemovePetitionsAndSigns(), Guild::Member::ResetFlags(), Guild::Member::SaveToDB(), sCharacterCache, SendLoginInfo(), PreparedStatementBase::SetData(), Player::SetGuildIdInvited(), Player::SetInGuild(), Player::SetRank(), Guild::Member::SetStats(), sScriptMgr, and ObjectGuid::ToString().

Referenced by Create(), HandleAcceptMember(), guild_commandscript::HandleGuildInviteCommand(), and WorldSession::HandleTurnInPetitionOpcode().

◆ BroadcastPacket()

void Guild::BroadcastPacket ( WorldPacket const *  packet) const
2136{
2137 for (auto const& [guid, member] : m_members)
2138 if (Player* player = member.FindPlayer())
2139 player->GetSession()->SendPacket(packet);
2140}

References m_members.

Referenced by _BroadcastEvent(), and Guild::BankTab::SendText().

◆ BroadcastPacketToRank()

void Guild::BroadcastPacketToRank ( WorldPacket const *  packet,
uint8  rankId 
) const
2128{
2129 for (auto const& [guid, member] : m_members)
2130 if (member.IsRank(rankId))
2131 if (Player* player = member.FindPlayer())
2132 player->GetSession()->SendPacket(packet);
2133}

References m_members.

◆ BroadcastToGuild()

void Guild::BroadcastToGuild ( WorldSession session,
bool  officerOnly,
std::string_view  msg,
uint32  language = LANG_UNIVERSAL 
) const
2115{
2116 if (session && session->GetPlayer() && _HasRankRight(session->GetPlayer(), officerOnly ? GR_RIGHT_OFFCHATSPEAK : GR_RIGHT_GCHATSPEAK))
2117 {
2118 WorldPacket data;
2119 ChatHandler::BuildChatPacket(data, officerOnly ? CHAT_MSG_OFFICER : CHAT_MSG_GUILD, Language(language), session->GetPlayer(), nullptr, msg);
2120 for (auto const& [guid, member] : m_members)
2121 if (Player* player = member.FindPlayer())
2122 if (_HasRankRight(player, officerOnly ? GR_RIGHT_OFFCHATLISTEN : GR_RIGHT_GCHATLISTEN) && !player->GetSocial()->HasIgnore(session->GetPlayer()->GetGUID()))
2123 player->GetSession()->SendPacket(&data);
2124 }
2125}
@ GR_RIGHT_OFFCHATSPEAK
Definition: Guild.h:83
@ GR_RIGHT_OFFCHATLISTEN
Definition: Guild.h:82
@ CHAT_MSG_GUILD
Definition: SharedDefines.h:3156
@ CHAT_MSG_OFFICER
Definition: SharedDefines.h:3157
Language
Definition: SharedDefines.h:734
static std::size_t BuildChatPacket(WorldPacket &data, ChatMsg chatType, Language language, ObjectGuid senderGUID, ObjectGuid receiverGUID, std::string_view message, uint8 chatTag, std::string const &senderName="", std::string const &receiverName="", uint32 achievementId=0, bool gmMessage=false, std::string const &channelName="")
Definition: Chat.cpp:267
bool _HasRankRight(Player *player, uint32 right) const
Definition: Guild.h:809
Definition: WorldPacket.h:27

References _HasRankRight(), ChatHandler::BuildChatPacket(), CHAT_MSG_GUILD, CHAT_MSG_OFFICER, Object::GetGUID(), WorldSession::GetPlayer(), GR_RIGHT_GCHATLISTEN, GR_RIGHT_GCHATSPEAK, GR_RIGHT_OFFCHATLISTEN, GR_RIGHT_OFFCHATSPEAK, and m_members.

◆ BroadcastWorker()

template<class Do >
void Guild::BroadcastWorker ( Do &  _do,
Player except = nullptr 
)
inline
755 {
756 for (auto const& m_member : m_members)
757 if (Player* player = m_member.second.FindPlayer())
758 if (player != except)
759 _do(player);
760 }

References m_members.

Referenced by AchievementMgr::SendAchievementEarned().

◆ ChangeMemberRank()

bool Guild::ChangeMemberRank ( ObjectGuid  guid,
uint8  newRank 
)
2321{
2322 if (newRank <= _GetLowestRankId()) // Validate rank (allow only existing ranks)
2323 if (Member* member = GetMember(guid))
2324 {
2325 member->ChangeRank(newRank);
2326
2327 if (newRank == GR_GUILDMASTER)
2328 {
2329 m_leaderGuid = guid;
2330
2332 stmt->SetData(0, m_leaderGuid.GetCounter());
2333 stmt->SetData(1, m_id);
2334 CharacterDatabase.Execute(stmt);
2335 }
2336
2337 return true;
2338 }
2339 return false;
2340}

References _GetLowestRankId(), CHAR_UPD_GUILD_LEADER, CharacterDatabase, ObjectGuid::GetCounter(), GetMember(), GR_GUILDMASTER, m_id, m_leaderGuid, and PreparedStatementBase::SetData().

Referenced by guild_commandscript::HandleGuildRankCommand().

◆ Create()

bool Guild::Create ( Player pLeader,
std::string_view  name 
)
1050{
1051 // Check if guild with such name already exists
1052 if (sGuildMgr->GetGuildByName(name))
1053 return false;
1054
1055 WorldSession* pLeaderSession = pLeader->GetSession();
1056 if (!pLeaderSession)
1057 return false;
1058
1059 m_id = sGuildMgr->GenerateGuildId();
1060 m_leaderGuid = pLeader->GetGUID();
1061 m_name = name;
1062 m_info = "";
1063 m_motd = "No message set.";
1064 m_bankMoney = 0;
1066
1067 LOG_DEBUG("guild", "GUILD: creating guild [{}] for leader {} ({})",
1068 m_name, pLeader->GetName(), m_leaderGuid.ToString());
1069
1070 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
1071
1073 stmt->SetData(0, m_id);
1074 trans->Append(stmt);
1075
1076 uint8 index = 0;
1077 stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD);
1078 stmt->SetData( index, m_id);
1079 stmt->SetData(++index, m_name);
1080 stmt->SetData(++index, m_leaderGuid.GetCounter());
1081 stmt->SetData(++index, m_info);
1082 stmt->SetData(++index, m_motd);
1083 stmt->SetData(++index, uint32(m_createdDate));
1084 stmt->SetData(++index, m_emblemInfo.GetStyle());
1085 stmt->SetData(++index, m_emblemInfo.GetColor());
1086 stmt->SetData(++index, m_emblemInfo.GetBorderStyle());
1087 stmt->SetData(++index, m_emblemInfo.GetBorderColor());
1088 stmt->SetData(++index, m_emblemInfo.GetBackgroundColor());
1089 stmt->SetData(++index, m_bankMoney);
1090 trans->Append(stmt);
1091
1092 CharacterDatabase.CommitTransaction(trans);
1093 _CreateDefaultGuildRanks(pLeaderSession->GetSessionDbLocaleIndex()); // Create default ranks
1094 bool ret = AddMember(m_leaderGuid, GR_GUILDMASTER); // Add guildmaster
1095
1096 for (short i = 0; i < static_cast<short>(sWorld->getIntConfig(CONFIG_GUILD_BANK_INITIAL_TABS)); i++)
1097 {
1099 }
1100
1101 if (ret)
1102 sScriptMgr->OnGuildCreate(this, pLeader, m_name);
1103
1104 return ret;
1105}
#define sGuildMgr
Definition: GuildMgr.h:51
@ CONFIG_GUILD_BANK_INITIAL_TABS
Definition: IWorld.h:407
@ CHAR_INS_GUILD
Definition: CharacterDatabase.h:140
@ CHAR_DEL_GUILD_MEMBERS
Definition: CharacterDatabase.h:145
#define sWorld
Definition: World.h:444
Seconds GetGameTime()
Definition: GameTime.cpp:38
uint32 GetStyle() const
Definition: Guild.h:250
uint32 GetColor() const
Definition: Guild.h:251
uint32 GetBackgroundColor() const
Definition: Guild.h:254
uint32 GetBorderStyle() const
Definition: Guild.h:252
uint32 GetBorderColor() const
Definition: Guild.h:253
void _CreateNewBankTab()
Definition: Guild.cpp:2381
bool AddMember(ObjectGuid guid, uint8 rankId=GUILD_RANK_NONE)
Definition: Guild.cpp:2175
std::string m_motd
Definition: Guild.h:789
EmblemInfo m_emblemInfo
Definition: Guild.h:793
std::string m_info
Definition: Guild.h:790
void _CreateDefaultGuildRanks(LocaleConstant loc)
Definition: Guild.cpp:2405
Player session in the World.
Definition: WorldSession.h:330
LocaleConstant GetSessionDbLocaleIndex() const
Definition: WorldSession.h:498

References _CreateDefaultGuildRanks(), _CreateNewBankTab(), AddMember(), CHAR_DEL_GUILD_MEMBERS, CHAR_INS_GUILD, CharacterDatabase, CONFIG_GUILD_BANK_INITIAL_TABS, EmblemInfo::GetBackgroundColor(), EmblemInfo::GetBorderColor(), EmblemInfo::GetBorderStyle(), EmblemInfo::GetColor(), ObjectGuid::GetCounter(), GameTime::GetGameTime(), Object::GetGUID(), WorldObject::GetName(), Player::GetSession(), WorldSession::GetSessionDbLocaleIndex(), EmblemInfo::GetStyle(), GR_GUILDMASTER, LOG_DEBUG, m_bankMoney, m_createdDate, m_emblemInfo, m_id, m_info, m_leaderGuid, m_motd, m_name, PreparedStatementBase::SetData(), sGuildMgr, sScriptMgr, sWorld, and ObjectGuid::ToString().

Referenced by guild_commandscript::HandleGuildCreateCommand(), and WorldSession::HandleTurnInPetitionOpcode().

◆ DeleteMember()

void Guild::DeleteMember ( ObjectGuid  guid,
bool  isDisbanding = false,
bool  isKicked = false,
bool  canDeleteGuild = false 
)
2260{
2261 ObjectGuid::LowType lowguid = guid.GetCounter();
2263
2264 // Guild master can be deleted when loading guild and guid doesn't exist in characters table
2265 // or when he is removed from guild by gm command
2266 if (m_leaderGuid == guid && !isDisbanding)
2267 {
2268 Member* oldLeader = nullptr;
2269 Member* newLeader = nullptr;
2270 for (auto& [guid, member] : m_members)
2271 {
2272 if (guid == lowguid)
2273 oldLeader = &member;
2274 else if (!newLeader || newLeader->GetRankId() > member.GetRankId())
2275 newLeader = &member;
2276 }
2277
2278 if (!newLeader)
2279 {
2280 Disband();
2281 if (canDeleteGuild)
2282 delete this;
2283 return;
2284 }
2285
2286 _SetLeaderGUID(*newLeader);
2287
2288 // If player not online data in data field will be loaded from guild tabs no need to update it !!
2289 if (Player* newLeaderPlayer = newLeader->FindPlayer())
2290 newLeaderPlayer->SetRank(GR_GUILDMASTER);
2291
2292 // If leader does not exist (at guild loading with deleted leader) do not send broadcasts
2293 if (oldLeader)
2294 {
2295 _BroadcastEvent(GE_LEADER_CHANGED, ObjectGuid::Empty, oldLeader->GetName(), newLeader->GetName());
2296 _BroadcastEvent(GE_LEFT, guid, oldLeader->GetName());
2297 }
2298 }
2299 // Call script on remove before member is actually removed from guild (and database)
2300 sScriptMgr->OnGuildRemoveMember(this, player, isDisbanding, isKicked);
2301
2302 m_members.erase(lowguid);
2303
2304 // If player not online data in data field will be loaded from guild tabs no need to update it !!
2305 if (player)
2306 {
2307 player->SetInGuild(0);
2308 player->SetRank(0);
2309 }
2310 else
2311 {
2312 sCharacterCache->UpdateCharacterGuildId(guid, 0);
2313 }
2314
2316 if (!isDisbanding)
2318}
@ GE_LEFT
Definition: Guild.h:154
@ GE_LEADER_CHANGED
Definition: Guild.h:157
static ObjectGuid const Empty
Definition: ObjectGuid.h:120
void _SetLeaderGUID(Member &pLeader)
Definition: Guild.cpp:2492
void Disband()
Definition: Guild.cpp:1108
void _DeleteMemberFromDB(ObjectGuid::LowType lowguid) const
Definition: Guild.h:823

References _BroadcastEvent(), _DeleteMemberFromDB(), _SetLeaderGUID(), _UpdateAccountsNumber(), Disband(), ObjectGuid::Empty, ObjectAccessor::FindConnectedPlayer(), Guild::Member::FindPlayer(), GE_LEADER_CHANGED, GE_LEFT, ObjectGuid::GetCounter(), Guild::Member::GetName(), Guild::Member::GetRankId(), GR_GUILDMASTER, m_leaderGuid, m_members, sCharacterCache, Player::SetInGuild(), Player::SetRank(), and sScriptMgr.

Referenced by Disband(), guild_commandscript::HandleGuildUninviteCommand(), HandleLeaveMember(), HandleRemoveMember(), and Validate().

◆ Disband()

void Guild::Disband ( )
1109{
1110 // Call scripts before guild data removed from database
1111 sScriptMgr->OnGuildDisband(this);
1112
1114 // Remove all members
1115 while (!m_members.empty())
1116 {
1117 auto itr = m_members.begin();
1118 DeleteMember(itr->second.GetGUID(), true);
1119 }
1120
1121 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
1122
1124 stmt->SetData(0, m_id);
1125 trans->Append(stmt);
1126
1127 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_RANKS);
1128 stmt->SetData(0, m_id);
1129 trans->Append(stmt);
1130
1131 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_TABS);
1132 stmt->SetData(0, m_id);
1133 trans->Append(stmt);
1134
1135 // Free bank tab used memory and delete items stored in them
1136 _DeleteBankItems(trans, true);
1137
1138 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_ITEMS);
1139 stmt->SetData(0, m_id);
1140 trans->Append(stmt);
1141
1142 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_RIGHTS);
1143 stmt->SetData(0, m_id);
1144 trans->Append(stmt);
1145
1146 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_EVENTLOGS);
1147 stmt->SetData(0, m_id);
1148 trans->Append(stmt);
1149
1150 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_EVENTLOGS);
1151 stmt->SetData(0, m_id);
1152 trans->Append(stmt);
1153
1154 CharacterDatabase.CommitTransaction(trans);
1155 sGuildMgr->RemoveGuild(m_id);
1156}
@ GE_DISBANDED
Definition: Guild.h:158
@ CHAR_DEL_GUILD_BANK_TABS
Definition: CharacterDatabase.h:152
@ CHAR_DEL_GUILD
Definition: CharacterDatabase.h:141
@ CHAR_DEL_GUILD_BANK_EVENTLOGS
Definition: CharacterDatabase.h:161
@ CHAR_DEL_GUILD_BANK_ITEMS
Definition: CharacterDatabase.h:155
@ CHAR_DEL_GUILD_EVENTLOGS
Definition: CharacterDatabase.h:164
void DeleteMember(ObjectGuid guid, bool isDisbanding=false, bool isKicked=false, bool canDeleteGuild=false)
Definition: Guild.cpp:2259

References _BroadcastEvent(), _DeleteBankItems(), CHAR_DEL_GUILD, CHAR_DEL_GUILD_BANK_EVENTLOGS, CHAR_DEL_GUILD_BANK_ITEMS, CHAR_DEL_GUILD_BANK_RIGHTS, CHAR_DEL_GUILD_BANK_TABS, CHAR_DEL_GUILD_EVENTLOGS, CHAR_DEL_GUILD_RANKS, CharacterDatabase, DeleteMember(), GE_DISBANDED, m_id, m_members, PreparedStatementBase::SetData(), sGuildMgr, and sScriptMgr.

Referenced by DeleteMember(), HandleDisband(), guild_commandscript::HandleGuildDeleteCommand(), HandleLeaveMember(), and Validate().

◆ GetBankTab() [1/2]

BankTab * Guild::GetBankTab ( uint8  tabId)
inlineprivate
820{ return tabId < m_bankTabs.size() ? &m_bankTabs[tabId] : nullptr; }

References m_bankTabs.

Referenced by _GetItem(), _RemoveItem(), _SendBankList(), HandleSetBankTabInfo(), SendBankTabText(), and SetBankTabText().

◆ GetBankTab() [2/2]

BankTab const * Guild::GetBankTab ( uint8  tabId) const
inlineprivate
821{ return tabId < m_bankTabs.size() ? &m_bankTabs[tabId] : nullptr; }

References m_bankTabs.

◆ GetCreatedDate()

time_t Guild::GetCreatedDate ( ) const
inline

◆ GetId()

◆ GetInfo()

std::string const & Guild::GetInfo ( ) const
inline
693{ return m_info; }

References m_info.

Referenced by guild_commandscript::HandleGuildInfoCommand().

◆ GetLeaderGUID()

◆ GetMember() [1/3]

Member * Guild::GetMember ( ObjectGuid  guid)
inline
390 {
391 auto itr = m_members.find(guid.GetCounter());
392 return (itr != m_members.end()) ? &itr->second : nullptr;
393 }

References ObjectGuid::GetCounter(), and m_members.

◆ GetMember() [2/3]

◆ GetMember() [3/3]

Member * Guild::GetMember ( std::string_view  name)
inline
395 {
396 for (auto& m_member : m_members)
397 if (m_member.second.GetName() == name)
398 return &m_member.second;
399
400 return nullptr;
401 }

References m_members.

◆ GetMemberCount()

uint32 Guild::GetMemberCount ( ) const
inline

◆ GetMemberSize()

uint32 Guild::GetMemberSize ( ) const
inline
783{ return m_members.size(); }

References m_members.

◆ GetMOTD()

std::string const & Guild::GetMOTD ( ) const
inline
692{ return m_motd; }

References m_motd.

Referenced by guild_commandscript::HandleGuildInfoCommand().

◆ GetName()

◆ GetRankInfo() [1/2]

RankInfo * Guild::GetRankInfo ( uint8  rankId)
inlineprivate
808{ return rankId < _GetRanksSize() ? &m_ranks[rankId] : nullptr; }

References _GetRanksSize(), and m_ranks.

◆ GetRankInfo() [2/2]

const RankInfo * Guild::GetRankInfo ( uint8  rankId) const
inlineprivate

◆ GetTotalBankMoney()

uint64 Guild::GetTotalBankMoney ( ) const
inline

◆ HandleAcceptMember()

void Guild::HandleAcceptMember ( WorldSession session)
1496{
1497 Player* player = session->GetPlayer();
1498 if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && player->GetTeamId() != sCharacterCache->GetCharacterTeamByGuid(GetLeaderGUID()))
1499 {
1500 return;
1501 }
1502
1503 AddMember(player->GetGUID());
1504}
@ CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD
Definition: IWorld.h:81
TeamId GetTeamId(bool original=false) const
Definition: Player.h:2088
ObjectGuid GetLeaderGUID() const
Definition: Guild.h:690

References AddMember(), CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD, Object::GetGUID(), GetLeaderGUID(), WorldSession::GetPlayer(), Player::GetTeamId(), sCharacterCache, and sWorld.

◆ HandleAddNewRank()

void Guild::HandleAddNewRank ( WorldSession session,
std::string_view  name 
)
1622{
1623 uint8 size = _GetRanksSize();
1624 if (size >= GUILD_RANKS_MAX_COUNT)
1625 return;
1626
1627 // Only leader can add new rank
1628 if (_IsLeader(session->GetPlayer()))
1630 _BroadcastEvent(GE_RANK_UPDATED, ObjectGuid::Empty, std::to_string(size), name, std::to_string(m_ranks.size()));
1631}
@ GE_RANK_UPDATED
Definition: Guild.h:160
bool _IsLeader(Player *player) const
Definition: Guild.cpp:2455

References _BroadcastEvent(), _CreateRank(), _GetRanksSize(), _IsLeader(), ObjectGuid::Empty, GE_RANK_UPDATED, WorldSession::GetPlayer(), GR_RIGHT_GCHATLISTEN, GR_RIGHT_GCHATSPEAK, GUILD_RANKS_MAX_COUNT, and m_ranks.

◆ HandleBuyBankTab()

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

Hack to force client to update permissions

1404{
1405 Player* player = session->GetPlayer();
1406 if (!player)
1407 return;
1408
1409 Member const* member = GetMember(player->GetGUID());
1410 if (!member)
1411 return;
1412
1414 return;
1415
1416 if (tabId != _GetPurchasedTabsSize())
1417 return;
1418
1419 uint32 tabCost = _GetGuildBankTabPrice(tabId);
1420 if (!tabCost)
1421 return;
1422
1423 if (!player->HasEnoughMoney(tabCost)) // Should not happen, this is checked by client
1424 return;
1425
1426 player->ModifyMoney(-int32(tabCost));
1427
1430 SendPermissions(session);
1431}
@ GE_BANK_TAB_PURCHASED
Definition: Guild.h:165
uint32 _GetGuildBankTabPrice(uint8 tabId)
Definition: Guild.cpp:93
bool ModifyMoney(int32 amount, bool sendError=true)
Definition: Player.cpp:11511
bool HasEnoughMoney(uint32 amount) const
Definition: Player.h:1598
void SendPermissions(WorldSession *session)
Definition: Guild.cpp:1834

References _BroadcastEvent(), _CreateNewBankTab(), _GetGuildBankTabPrice(), _GetPurchasedTabsSize(), GE_BANK_TAB_PURCHASED, Object::GetGUID(), GetMember(), WorldSession::GetPlayer(), GUILD_BANK_MAX_TABS, Player::HasEnoughMoney(), Player::ModifyMoney(), and SendPermissions().

◆ HandleDisband()

void Guild::HandleDisband ( WorldSession session)
1755{
1756 // Only leader can disband guild
1757 if (_IsLeader(session->GetPlayer()))
1758 {
1759 Disband();
1760 LOG_DEBUG("guild", "Guild Successfully Disbanded");
1761 delete this;
1762 }
1763}

References _IsLeader(), Disband(), WorldSession::GetPlayer(), and LOG_DEBUG.

◆ HandleInviteMember()

void Guild::HandleInviteMember ( WorldSession session,
std::string const &  name 
)
1434{
1435 Player* pInvitee = ObjectAccessor::FindPlayerByName(name, false);
1436 if (!pInvitee)
1437 {
1439 return;
1440 }
1441
1442 Player* player = session->GetPlayer();
1443 // Do not show invitations from ignored players
1444 if (pInvitee->GetSocial()->HasIgnore(player->GetGUID()))
1445 return;
1446
1447 uint32 memberLimit = sConfigMgr->GetOption<uint32>("Guild.MemberLimit", 0);
1448 if (memberLimit > 0 && player->GetGuild()->GetMemberCount() >= memberLimit)
1449 {
1450 ChatHandler(player->GetSession()).PSendSysMessage("Your guild has reached the maximum amount of members ({}). You cannot send another invite until the guild member count is lower.", memberLimit);
1452 return;
1453 }
1454
1455 if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && pInvitee->GetTeamId(true) != player->GetTeamId(true))
1456 {
1458 return;
1459 }
1460 // Invited player cannot be in another guild
1461 if (pInvitee->GetGuildId())
1462 {
1464 return;
1465 }
1466 // Invited player cannot be invited
1467 if (pInvitee->GetGuildIdInvited())
1468 {
1470 return;
1471 }
1472 // Inviting player must have rights to invite
1473 if (!_HasRankRight(player, GR_RIGHT_INVITE))
1474 {
1476 return;
1477 }
1478
1480
1481 LOG_DEBUG("guild", "Player {} invited {} to join his Guild", player->GetName(), pInvitee->GetName());
1482
1483 pInvitee->SetGuildIdInvited(m_id);
1484 _LogEvent(GUILD_EVENT_LOG_INVITE_PLAYER, player->GetGUID(), pInvitee->GetGUID());
1485
1487
1488 invite.InviterName = player->GetName();
1489 invite.GuildName = GetName();
1490
1491 pInvitee->SendDirectMessage(invite.Write());
1492 LOG_DEBUG("guild", "SMSG_GUILD_INVITE [{}]", pInvitee->GetName());
1493}
#define sConfigMgr
Definition: Config.h:74
@ GUILD_COMMAND_INVITE
Definition: Guild.h:103
@ ERR_GUILD_PERMISSIONS
Definition: Guild.h:131
@ ERR_ALREADY_IN_GUILD_S
Definition: Guild.h:125
@ ERR_GUILD_COMMAND_SUCCESS
Definition: Guild.h:122
@ ERR_GUILD_NOT_ALLIED
Definition: Guild.h:135
@ ERR_GUILD_INTERNAL
Definition: Guild.h:123
@ ERR_GUILD_PLAYER_NOT_FOUND_S
Definition: Guild.h:134
@ ERR_ALREADY_INVITED_TO_GUILD_S
Definition: Guild.h:127
@ GR_RIGHT_INVITE
Definition: Guild.h:84
@ GUILD_EVENT_LOG_INVITE_PLAYER
Definition: Guild.h:213
Player * FindPlayerByName(std::string const &name, bool checkInWorld=true)
Definition: ObjectAccessor.cpp:274
Definition: Chat.h:39
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:213
uint32 GetGuildIdInvited()
Definition: Player.h:1883
Guild * GetGuild() const
Definition: Player.cpp:16006
PlayerSocial * GetSocial()
Definition: Player.h:1141
bool HasIgnore(ObjectGuid ignore_guid) const
Definition: SocialMgr.cpp:193
uint32 GetMemberCount() const
Definition: Guild.h:774
std::string const & GetName() const
Definition: Guild.h:691
static void SendCommandResult(WorldSession *session, GuildCommandType type, GuildCommandError errCode, std::string_view param={})
Definition: Guild.cpp:114
Definition: GuildPackets.h:192
WorldPacket const * Write() override
Definition: GuildPackets.cpp:95
std::string InviterName
Definition: GuildPackets.h:198
std::string GuildName
Definition: GuildPackets.h:199

References _HasRankRight(), _LogEvent(), CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD, ERR_ALREADY_IN_GUILD_S, ERR_ALREADY_INVITED_TO_GUILD_S, ERR_GUILD_COMMAND_SUCCESS, ERR_GUILD_INTERNAL, ERR_GUILD_NOT_ALLIED, ERR_GUILD_PERMISSIONS, ERR_GUILD_PLAYER_NOT_FOUND_S, ObjectAccessor::FindPlayerByName(), Object::GetGUID(), Player::GetGuild(), Player::GetGuildId(), Player::GetGuildIdInvited(), GetMemberCount(), WorldObject::GetName(), GetName(), WorldSession::GetPlayer(), Player::GetSession(), Player::GetSocial(), Player::GetTeamId(), GR_RIGHT_INVITE, GUILD_COMMAND_INVITE, GUILD_EVENT_LOG_INVITE_PLAYER, WorldPackets::Guild::GuildInvite::GuildName, PlayerSocial::HasIgnore(), WorldPackets::Guild::GuildInvite::InviterName, LOG_DEBUG, m_id, ChatHandler::PSendSysMessage(), sConfigMgr, SendCommandResult(), Player::SendDirectMessage(), Player::SetGuildIdInvited(), sWorld, and WorldPackets::Guild::GuildInvite::Write().

◆ HandleLeaveMember()

void Guild::HandleLeaveMember ( WorldSession session)
1507{
1508 Player* player = session->GetPlayer();
1509 bool disband = false;
1510
1511 // If leader is leaving
1512 if (_IsLeader(player))
1513 {
1514 if (m_members.size() > 1)
1515 // Leader cannot leave if he is not the last member
1517 else
1518 {
1519 // Guild is disbanded if leader leaves.
1520 Disband();
1521 disband = true;
1522 }
1523 }
1524 else
1525 {
1526 DeleteMember(player->GetGUID(), false, false);
1527
1529 _BroadcastEvent(GE_LEFT, player->GetGUID(), player->GetName());
1530
1532 }
1533
1534 sCalendarMgr->RemovePlayerGuildEventsAndSignups(player->GetGUID(), GetId());
1535
1536 if (disband)
1537 delete this;
1538}
@ GUILD_COMMAND_QUIT
Definition: Guild.h:104
@ ERR_GUILD_LEADER_LEAVE
Definition: Guild.h:130
@ GUILD_EVENT_LOG_LEAVE_GUILD
Definition: Guild.h:218
#define sCalendarMgr
Definition: CalendarMgr.h:344
uint32 GetId() const
Definition: Guild.h:689

References _BroadcastEvent(), _IsLeader(), _LogEvent(), DeleteMember(), Disband(), ERR_GUILD_COMMAND_SUCCESS, ERR_GUILD_LEADER_LEAVE, GE_LEFT, Object::GetGUID(), GetId(), WorldObject::GetName(), WorldSession::GetPlayer(), GUILD_COMMAND_QUIT, GUILD_EVENT_LOG_LEAVE_GUILD, m_members, m_name, sCalendarMgr, and SendCommandResult().

◆ HandleMemberDepositMoney()

void Guild::HandleMemberDepositMoney ( WorldSession session,
uint32  amount 
)
1662{
1663 Player* player = session->GetPlayer();
1664
1665 // Call script after validation and before money transfer.
1666 sScriptMgr->OnGuildMemberDepositMoney(this, player, amount);
1667
1668 if (m_bankMoney > GUILD_BANK_MONEY_LIMIT - amount)
1669 {
1671 return;
1672 }
1673
1674 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
1675 _ModifyBankMoney(trans, amount, true);
1676
1677 player->ModifyMoney(-int32(amount));
1678 player->SaveGoldToDB(trans);
1679 _LogBankEvent(trans, GUILD_BANK_LOG_DEPOSIT_MONEY, uint8(0), player->GetGUID(), amount);
1680
1681 CharacterDatabase.CommitTransaction(trans);
1682
1683 std::string aux = Acore::Impl::ByteArrayToHexStr(reinterpret_cast<uint8*>(&m_bankMoney), 8, true);
1685
1686 if (amount > 10 * GOLD) // receiver_acc = Guild id, receiver_name = Guild name
1687 CharacterDatabase.Execute("INSERT INTO log_money VALUES({}, {}, \"{}\", \"{}\", {}, \"{}\", {}, \"(guild members: {}, new amount: {}, leader guid low: {}, sender level: {})\", NOW(), {})",
1688 session->GetAccountId(), player->GetGUID().GetCounter(), player->GetName(), session->GetRemoteAddress(), GetId(), GetName(), amount, GetMemberCount(), GetTotalBankMoney(), GetLeaderGUID().GetCounter(), player->GetLevel(), 3);
1689}
@ GE_BANK_MONEY_SET
Definition: Guild.h:167
constexpr uint64 GUILD_BANK_MONEY_LIMIT
Definition: Guild.h:57
@ GUILD_COMMAND_MOVE_ITEM
Definition: Guild.h:116
@ ERR_GUILD_BANK_FULL
Definition: Guild.h:144
@ GUILD_BANK_LOG_DEPOSIT_MONEY
Definition: Guild.h:203
@ GOLD
Definition: SharedDefines.h:253
AC_COMMON_API std::string ByteArrayToHexStr(uint8 const *bytes, std::size_t length, bool reverse=false)
Definition: Util.cpp:545
void SaveGoldToDB(CharacterDatabaseTransaction trans)
Definition: PlayerStorage.cpp:7132
uint8 GetLevel() const
Definition: Unit.h:855
bool _ModifyBankMoney(CharacterDatabaseTransaction trans, uint64 amount, bool add)
Definition: Guild.cpp:2473
void _LogBankEvent(CharacterDatabaseTransaction trans, GuildBankEventLogTypes eventType, uint8 tabId, ObjectGuid playerGuid, uint32 itemOrMoney, uint16 itemStackCount=0, uint8 destTabId=0)
Definition: Guild.cpp:2617
uint64 GetTotalBankMoney() const
Definition: Guild.h:773
uint32 GetAccountId() const
Definition: WorldSession.h:361
std::string const & GetRemoteAddress()
Definition: WorldSession.h:371

References _BroadcastEvent(), _LogBankEvent(), _ModifyBankMoney(), Acore::Impl::ByteArrayToHexStr(), CharacterDatabase, ObjectGuid::Empty, ERR_GUILD_BANK_FULL, GE_BANK_MONEY_SET, WorldSession::GetAccountId(), ObjectGuid::GetCounter(), Object::GetGUID(), GetId(), GetLeaderGUID(), Unit::GetLevel(), GetMemberCount(), WorldObject::GetName(), GetName(), WorldSession::GetPlayer(), WorldSession::GetRemoteAddress(), GetTotalBankMoney(), GOLD, GUILD_BANK_LOG_DEPOSIT_MONEY, GUILD_BANK_MONEY_LIMIT, GUILD_COMMAND_MOVE_ITEM, m_bankMoney, Player::ModifyMoney(), Player::SaveGoldToDB(), SendCommandResult(), and sScriptMgr.

◆ HandleMemberLogout()

void Guild::HandleMemberLogout ( WorldSession session)
1743{
1744 Player* player = session->GetPlayer();
1745 if (Member* member = GetMember(player->GetGUID()))
1746 {
1747 member->SetStats(player);
1748 member->UpdateLogoutTime();
1749 member->ResetFlags();
1750 }
1751 _BroadcastEvent(GE_SIGNED_OFF, player->GetGUID(), player->GetName());
1752}
@ GE_SIGNED_OFF
Definition: Guild.h:163

References _BroadcastEvent(), GE_SIGNED_OFF, Object::GetGUID(), GetMember(), WorldObject::GetName(), and WorldSession::GetPlayer().

◆ HandleMemberWithdrawMoney()

bool Guild::HandleMemberWithdrawMoney ( WorldSession session,
uint32  amount,
bool  repair = false 
)
1692{
1693 //clamp amount to MAX_MONEY_AMOUNT, Players can't hold more than that anyway
1694 amount = std::min(amount, uint32(MAX_MONEY_AMOUNT));
1695
1696 if (m_bankMoney < amount) // Not enough money in bank
1697 return false;
1698
1699 Player* player = session->GetPlayer();
1700
1701 Member* member = GetMember(player->GetGUID());
1702 if (!member)
1703 return false;
1704
1705 if (uint32(_GetMemberRemainingMoney(*member)) < amount) // Check if we have enough slot/money today
1706 return false;
1707
1708 if (!(_GetRankRights(member->GetRankId()) & GR_RIGHT_WITHDRAW_REPAIR) && repair)
1709 return false;
1710
1711 // Call script after validation and before money transfer.
1712 sScriptMgr->OnGuildMemberWitdrawMoney(this, player, amount, repair);
1713
1714 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
1715 // Add money to player (if required)
1716 if (!repair)
1717 {
1718 if (!player->ModifyMoney(amount))
1719 return false;
1720
1721 player->SaveGoldToDB(trans);
1722 }
1723
1724 // Update remaining money amount
1725 member->UpdateBankWithdrawValue(trans, GUILD_BANK_MAX_TABS, amount);
1726 // Remove money from bank
1727 _ModifyBankMoney(trans, amount, false);
1728
1729 // Log guild bank event
1731 CharacterDatabase.CommitTransaction(trans);
1732
1733 if (amount > 10 * GOLD) // sender_acc = 0 (guild has no account), sender_guid = Guild id, sender_name = Guild name
1734 CharacterDatabase.Execute("INSERT INTO log_money VALUES({}, {}, \"{}\", \"{}\", {}, \"{}\", {}, \"(guild, members: {}, new amount: {}, leader guid low: {}, withdrawer level: {})\", NOW(), {})",
1735 0, GetId(), GetName(), session->GetRemoteAddress(), session->GetAccountId(), player->GetName(), amount, GetMemberCount(), GetTotalBankMoney(), GetLeaderGUID().GetCounter(), player->GetLevel(), 4);
1736
1737 std::string aux = Acore::Impl::ByteArrayToHexStr(reinterpret_cast<uint8*>(&m_bankMoney), 8, true);
1739 return true;
1740}
@ GUILD_BANK_LOG_WITHDRAW_MONEY
Definition: Guild.h:204
@ GUILD_BANK_LOG_REPAIR_MONEY
Definition: Guild.h:205
#define MAX_MONEY_AMOUNT
Definition: Player.h:930
int32 _GetMemberRemainingMoney(Member const &member) const
Definition: Guild.cpp:2568

References _BroadcastEvent(), _GetMemberRemainingMoney(), _GetRankRights(), _LogBankEvent(), _ModifyBankMoney(), Acore::Impl::ByteArrayToHexStr(), CharacterDatabase, ObjectGuid::Empty, GE_BANK_MONEY_SET, WorldSession::GetAccountId(), Object::GetGUID(), GetId(), GetLeaderGUID(), Unit::GetLevel(), GetMember(), GetMemberCount(), WorldObject::GetName(), GetName(), WorldSession::GetPlayer(), Guild::Member::GetRankId(), WorldSession::GetRemoteAddress(), GetTotalBankMoney(), GOLD, GR_RIGHT_WITHDRAW_REPAIR, GUILD_BANK_LOG_REPAIR_MONEY, GUILD_BANK_LOG_WITHDRAW_MONEY, GUILD_BANK_MAX_TABS, m_bankMoney, MAX_MONEY_AMOUNT, Player::ModifyMoney(), Player::SaveGoldToDB(), sScriptMgr, and Guild::Member::UpdateBankWithdrawValue().

Referenced by Player::DurabilityRepair().

◆ HandleQuery()

void Guild::HandleQuery ( WorldSession session)
1251{
1253 response.GuildId = m_id;
1254
1260
1261 for (uint8 i = 0; i < _GetRanksSize(); ++i)
1262 response.Info.Ranks[i] = m_ranks[i].GetName();
1263
1264 response.Info.RankCount = _GetRanksSize();
1265
1266 response.Info.GuildName = m_name;
1267
1268 session->SendPacket(response.Write());
1269 LOG_DEBUG("guild", "SMSG_GUILD_QUERY_RESPONSE [{}]", session->GetPlayerInfo());
1270}
uint32 EmblemColor
Definition: GuildPackets.h:49
std::string GuildName
Definition: GuildPackets.h:43
uint32 EmblemStyle
Definition: GuildPackets.h:48
uint32 BackgroundColor
Definition: GuildPackets.h:52
uint32 BorderColor
Definition: GuildPackets.h:51
uint32 BorderStyle
Definition: GuildPackets.h:50
uint32 RankCount
Definition: GuildPackets.h:46
std::array< std::string, GUILD_RANKS_MAX_COUNT > Ranks
Definition: GuildPackets.h:45
Definition: GuildPackets.h:56
uint32 GuildId
Definition: GuildPackets.h:62
GuildInfo Info
Definition: GuildPackets.h:63
WorldPacket const * Write() override
Definition: GuildPackets.cpp:28

References _GetRanksSize(), WorldPackets::Guild::GuildInfo::BackgroundColor, WorldPackets::Guild::GuildInfo::BorderColor, WorldPackets::Guild::GuildInfo::BorderStyle, WorldPackets::Guild::GuildInfo::EmblemColor, WorldPackets::Guild::GuildInfo::EmblemStyle, EmblemInfo::GetBackgroundColor(), EmblemInfo::GetBorderColor(), EmblemInfo::GetBorderStyle(), EmblemInfo::GetColor(), WorldSession::GetPlayerInfo(), EmblemInfo::GetStyle(), WorldPackets::Guild::QueryGuildInfoResponse::GuildId, WorldPackets::Guild::GuildInfo::GuildName, WorldPackets::Guild::QueryGuildInfoResponse::Info, LOG_DEBUG, m_emblemInfo, m_id, m_name, m_ranks, WorldPackets::Guild::GuildInfo::RankCount, WorldPackets::Guild::GuildInfo::Ranks, WorldSession::SendPacket(), and WorldPackets::Guild::QueryGuildInfoResponse::Write().

Referenced by HandleSetEmblem().

◆ HandleRemoveLowestRank()

void Guild::HandleRemoveLowestRank ( WorldSession session)
1634{
1636}
void HandleRemoveRank(WorldSession *session, uint8 rankId)
Definition: Guild.cpp:1638

References _GetLowestRankId(), and HandleRemoveRank().

◆ HandleRemoveMember()

void Guild::HandleRemoveMember ( WorldSession session,
std::string_view  name 
)
1541{
1542 Player* player = session->GetPlayer();
1543 // Player must have rights to remove members
1544 if (!_HasRankRight(player, GR_RIGHT_REMOVE))
1546 else if (Member* member = GetMember(name))
1547 {
1548 // Guild masters cannot be removed
1549 if (member->IsRank(GR_GUILDMASTER))
1551 // Do not allow to remove player with the same rank or higher
1552 else
1553 {
1554 Member const* memberMe = GetMember(player->GetGUID());
1555 if (!memberMe || member->IsRankNotLower(memberMe->GetRankId()))
1557 else
1558 {
1559 ObjectGuid guid = member->GetGUID();
1560 // After call to DeleteMember pointer to member becomes invalid
1561 DeleteMember(guid, false, true);
1563 _BroadcastEvent(GE_REMOVED, ObjectGuid::Empty, member->GetName(), player->GetName());
1564 }
1565 }
1566 }
1567}
@ GE_REMOVED
Definition: Guild.h:155
@ GUILD_COMMAND_REMOVE
Definition: Guild.h:108
@ ERR_GUILD_RANK_TOO_HIGH_S
Definition: Guild.h:136
@ GR_RIGHT_REMOVE
Definition: Guild.h:85
@ GUILD_EVENT_LOG_UNINVITE_PLAYER
Definition: Guild.h:217

References _BroadcastEvent(), _HasRankRight(), _LogEvent(), DeleteMember(), ObjectGuid::Empty, ERR_GUILD_LEADER_LEAVE, ERR_GUILD_PERMISSIONS, ERR_GUILD_RANK_TOO_HIGH_S, GE_REMOVED, Object::GetGUID(), GetMember(), WorldObject::GetName(), WorldSession::GetPlayer(), Guild::Member::GetRankId(), GR_GUILDMASTER, GR_RIGHT_REMOVE, GUILD_COMMAND_REMOVE, GUILD_EVENT_LOG_UNINVITE_PLAYER, Guild::Member::IsRankNotLower(), and SendCommandResult().

◆ HandleRemoveRank()

void Guild::HandleRemoveRank ( WorldSession session,
uint8  rankId 
)
1639{
1640 // Cannot remove rank if total count is minimum allowed by the client or is not leader
1641 if (_GetRanksSize() <= GUILD_RANKS_MIN_COUNT || rankId >= _GetRanksSize() || !_IsLeader(session->GetPlayer()))
1642 return;
1643
1644 // Delete bank rights for rank
1646 stmt->SetData(0, m_id);
1647 stmt->SetData(1, rankId);
1648 CharacterDatabase.Execute(stmt);
1649 // Delete rank
1650 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_LOWEST_RANK);
1651 stmt->SetData(0, m_id);
1652 stmt->SetData(1, rankId);
1653 CharacterDatabase.Execute(stmt);
1654
1655 // match what the sql statement does
1656 m_ranks.erase(m_ranks.begin() + rankId, m_ranks.end());
1657
1658 _BroadcastEvent(GE_RANK_DELETED, ObjectGuid::Empty, std::to_string(m_ranks.size()));
1659}
@ GE_RANK_DELETED
Definition: Guild.h:161
@ GUILD_RANKS_MIN_COUNT
Definition: Guild.h:48
@ CHAR_DEL_GUILD_BANK_RIGHTS_FOR_RANK
Definition: CharacterDatabase.h:158
@ CHAR_DEL_GUILD_LOWEST_RANK
Definition: CharacterDatabase.h:149

References _BroadcastEvent(), _GetRanksSize(), _IsLeader(), CHAR_DEL_GUILD_BANK_RIGHTS_FOR_RANK, CHAR_DEL_GUILD_LOWEST_RANK, CharacterDatabase, ObjectGuid::Empty, GE_RANK_DELETED, WorldSession::GetPlayer(), GUILD_RANKS_MIN_COUNT, m_id, m_ranks, and PreparedStatementBase::SetData().

Referenced by HandleRemoveLowestRank().

◆ HandleRoster()

void Guild::HandleRoster ( WorldSession session)
1204{
1206
1207 roster.RankData.reserve(m_ranks.size());
1208 for (RankInfo const& rank : m_ranks)
1209 {
1210 WorldPackets::Guild::GuildRankData& rankData = roster.RankData.emplace_back();
1211
1212 rankData.Flags = rank.GetRights();
1213 rankData.WithdrawGoldLimit = rank.GetBankMoneyPerDay();
1214 for (uint8 i = 0; i < GUILD_BANK_MAX_TABS; ++i)
1215 {
1216 rankData.TabFlags[i] = rank.GetBankTabRights(i);
1217 rankData.TabWithdrawItemLimit[i] = rank.GetBankTabSlotsPerDay(i);
1218 }
1219 }
1220
1221 bool sendOfficerNote = _HasRankRight(session->GetPlayer(), GR_RIGHT_VIEWOFFNOTE);
1222 roster.MemberData.reserve(m_members.size());
1223 for (auto const& [guid, member] : m_members)
1224 {
1225 WorldPackets::Guild::GuildRosterMemberData& memberData = roster.MemberData.emplace_back();
1226
1227 memberData.Guid = member.GetGUID();
1228 memberData.RankID = int32(member.GetRankId());
1229 memberData.AreaID = int32(member.GetZoneId());
1230 memberData.LastSave = float(float(GameTime::GetGameTime().count() - member.GetLogoutTime()) / DAY);
1231
1232 memberData.Status = member.GetFlags();
1233 memberData.Level = member.GetLevel();
1234 memberData.ClassID = member.GetClass();
1235 memberData.Gender = member.GetGender();
1236
1237 memberData.Name = member.GetName();
1238 memberData.Note = member.GetPublicNote();
1239 if (sendOfficerNote)
1240 memberData.OfficerNote = member.GetOfficerNote();
1241 }
1242
1243 roster.WelcomeText = m_motd;
1244 roster.InfoText = m_info;
1245
1246 LOG_DEBUG("guild", "SMSG_GUILD_ROSTER [{}]", session->GetPlayerInfo());
1247 session->SendPacket(roster.Write());
1248}
constexpr auto DAY
Definition: Common.h:49
@ GR_RIGHT_VIEWOFFNOTE
Definition: Guild.h:90
Definition: GuildPackets.h:106
int32 RankID
Definition: GuildPackets.h:110
uint8 Level
Definition: GuildPackets.h:117
uint8 ClassID
Definition: GuildPackets.h:118
int32 AreaID
Definition: GuildPackets.h:111
ObjectGuid Guid
Definition: GuildPackets.h:107
std::string Note
Definition: GuildPackets.h:114
uint8 Status
Definition: GuildPackets.h:116
uint8 Gender
Definition: GuildPackets.h:119
float LastSave
Definition: GuildPackets.h:112
std::string Name
Definition: GuildPackets.h:113
std::string OfficerNote
Definition: GuildPackets.h:115
Definition: GuildPackets.h:123
uint32 WithdrawGoldLimit
Definition: GuildPackets.h:125
uint32 Flags
Definition: GuildPackets.h:124
uint32 TabWithdrawItemLimit[GUILD_BANK_MAX_TABS]
Definition: GuildPackets.h:127
uint32 TabFlags[GUILD_BANK_MAX_TABS]
Definition: GuildPackets.h:126
Definition: GuildPackets.h:131
WorldPacket const * Write() override
Definition: GuildPackets.cpp:60
std::string WelcomeText
Definition: GuildPackets.h:139
std::vector< GuildRankData > RankData
Definition: GuildPackets.h:138
std::vector< GuildRosterMemberData > MemberData
Definition: GuildPackets.h:137
std::string InfoText
Definition: GuildPackets.h:140

References _HasRankRight(), WorldPackets::Guild::GuildRosterMemberData::AreaID, WorldPackets::Guild::GuildRosterMemberData::ClassID, DAY, WorldPackets::Guild::GuildRankData::Flags, WorldPackets::Guild::GuildRosterMemberData::Gender, GameTime::GetGameTime(), WorldSession::GetPlayer(), WorldSession::GetPlayerInfo(), GR_RIGHT_VIEWOFFNOTE, WorldPackets::Guild::GuildRosterMemberData::Guid, GUILD_BANK_MAX_TABS, WorldPackets::Guild::GuildRoster::InfoText, WorldPackets::Guild::GuildRosterMemberData::LastSave, WorldPackets::Guild::GuildRosterMemberData::Level, LOG_DEBUG, m_info, m_members, m_motd, m_ranks, WorldPackets::Guild::GuildRoster::MemberData, WorldPackets::Guild::GuildRosterMemberData::Name, WorldPackets::Guild::GuildRosterMemberData::Note, WorldPackets::Guild::GuildRosterMemberData::OfficerNote, WorldPackets::Guild::GuildRoster::RankData, WorldPackets::Guild::GuildRosterMemberData::RankID, WorldSession::SendPacket(), WorldPackets::Guild::GuildRosterMemberData::Status, WorldPackets::Guild::GuildRankData::TabFlags, WorldPackets::Guild::GuildRankData::TabWithdrawItemLimit, WorldPackets::Guild::GuildRoster::WelcomeText, WorldPackets::Guild::GuildRankData::WithdrawGoldLimit, and WorldPackets::Guild::GuildRoster::Write().

Referenced by HandleSetMemberNote(), and SendLoginInfo().

◆ HandleSetBankTabInfo()

void Guild::HandleSetBankTabInfo ( WorldSession session,
uint8  tabId,
std::string_view  name,
std::string_view  icon 
)
1354{
1355 BankTab* tab = GetBankTab(tabId);
1356 if (!tab)
1357 {
1358 LOG_ERROR("guild", "Guild::HandleSetBankTabInfo: Player {} trying to change bank tab info from unexisting tab {}.",
1359 session->GetPlayerInfo(), tabId);
1360 return;
1361 }
1362
1363 tab->SetInfo(name, icon);
1364 _BroadcastEvent(GE_BANK_TAB_UPDATED, ObjectGuid::Empty, std::to_string(tabId), tab->GetName(), tab->GetIcon());
1365}
@ GE_BANK_TAB_UPDATED
Definition: Guild.h:166

References _BroadcastEvent(), ObjectGuid::Empty, GE_BANK_TAB_UPDATED, GetBankTab(), Guild::BankTab::GetIcon(), Guild::BankTab::GetName(), WorldSession::GetPlayerInfo(), LOG_ERROR, and Guild::BankTab::SetInfo().

◆ HandleSetEmblem()

void Guild::HandleSetEmblem ( WorldSession session,
const EmblemInfo emblemInfo 
)
1315{
1316 Player* player = session->GetPlayer();
1317 if (!_IsLeader(player))
1318 SendSaveEmblemResult(session, ERR_GUILDEMBLEM_NOTGUILDMASTER); // "Only guild leaders can create emblems."
1319 else if (!player->HasEnoughMoney(EMBLEM_PRICE))
1320 SendSaveEmblemResult(session, ERR_GUILDEMBLEM_NOTENOUGHMONEY); // "You can't afford to do that."
1321 else
1322 {
1323 player->ModifyMoney(-int32(EMBLEM_PRICE));
1324
1325 m_emblemInfo = emblemInfo;
1327
1328 SendSaveEmblemResult(session, ERR_GUILDEMBLEM_SUCCESS); // "Guild Emblem saved."
1329
1330 HandleQuery(session);
1331 }
1332}
@ ERR_GUILDEMBLEM_NOTGUILDMASTER
Definition: Guild.h:226
@ ERR_GUILDEMBLEM_NOTENOUGHMONEY
Definition: Guild.h:227
@ ERR_GUILDEMBLEM_SUCCESS
Definition: Guild.h:223
#define EMBLEM_PRICE
Definition: Guild.cpp:41
void SaveToDB(uint32 guildId) const
Definition: Guild.cpp:701
void HandleQuery(WorldSession *session)
Definition: Guild.cpp:1250
static void SendSaveEmblemResult(WorldSession *session, GuildEmblemError errCode)
Definition: Guild.cpp:125

References _IsLeader(), EMBLEM_PRICE, ERR_GUILDEMBLEM_NOTENOUGHMONEY, ERR_GUILDEMBLEM_NOTGUILDMASTER, ERR_GUILDEMBLEM_SUCCESS, WorldSession::GetPlayer(), HandleQuery(), Player::HasEnoughMoney(), m_emblemInfo, m_id, Player::ModifyMoney(), EmblemInfo::SaveToDB(), and SendSaveEmblemResult().

◆ HandleSetInfo()

void Guild::HandleSetInfo ( WorldSession session,
std::string_view  info 
)
1296{
1297 if (m_info == info)
1298 return;
1299
1300 // Player must have rights to set guild's info
1302 {
1303 m_info = info;
1304
1305 sScriptMgr->OnGuildInfoChanged(this, m_info);
1306
1308 stmt->SetData(0, m_info);
1309 stmt->SetData(1, m_id);
1310 CharacterDatabase.Execute(stmt);
1311 }
1312}
@ GR_RIGHT_MODIFY_GUILD_INFO
Definition: Guild.h:92
@ CHAR_UPD_GUILD_INFO
Definition: CharacterDatabase.h:169

References _HasRankRight(), CHAR_UPD_GUILD_INFO, CharacterDatabase, WorldSession::GetPlayer(), GR_RIGHT_MODIFY_GUILD_INFO, m_id, m_info, PreparedStatementBase::SetData(), and sScriptMgr.

◆ HandleSetLeader()

void Guild::HandleSetLeader ( WorldSession session,
std::string_view  name 
)
1335{
1336 Player* player = session->GetPlayer();
1337 // Only leader can assign new leader
1338 if (!_IsLeader(player))
1340 // Old leader must be a member of guild
1341 else if (Member* pOldLeader = GetMember(player->GetGUID()))
1342 {
1343 // New leader must be a member of guild
1344 if (Member* pNewLeader = GetMember(name))
1345 {
1346 _SetLeaderGUID(*pNewLeader);
1347 pOldLeader->ChangeRank(GR_OFFICER);
1348 _BroadcastEvent(GE_LEADER_CHANGED, ObjectGuid::Empty, player->GetName(), pNewLeader->GetName());
1349 }
1350 }
1351}
@ GUILD_COMMAND_CHANGE_LEADER
Definition: Guild.h:109
@ GR_OFFICER
Definition: Guild.h:69

References _BroadcastEvent(), _IsLeader(), _SetLeaderGUID(), ObjectGuid::Empty, ERR_GUILD_PERMISSIONS, GE_LEADER_CHANGED, Object::GetGUID(), GetMember(), WorldObject::GetName(), WorldSession::GetPlayer(), GR_OFFICER, GUILD_COMMAND_CHANGE_LEADER, and SendCommandResult().

◆ HandleSetMemberNote()

void Guild::HandleSetMemberNote ( WorldSession session,
std::string_view  name,
std::string_view  note,
bool  officer 
)
1368{
1369 // Player must have rights to set public/officer note
1370 if (!_HasRankRight(session->GetPlayer(), isPublic ? GR_RIGHT_EPNOTE : GR_RIGHT_EOFFNOTE))
1372 else if (Member* member = GetMember(name))
1373 {
1374 if (isPublic)
1375 member->SetPublicNote(note);
1376 else
1377 member->SetOfficerNote(note);
1378
1379 HandleRoster(session);
1380 }
1381}
@ GUILD_COMMAND_PUBLIC_NOTE
Definition: Guild.h:114
@ GR_RIGHT_EOFFNOTE
Definition: Guild.h:91
@ GR_RIGHT_EPNOTE
Definition: Guild.h:89
void HandleRoster(WorldSession *session)
Definition: Guild.cpp:1203

References _HasRankRight(), ERR_GUILD_PERMISSIONS, GetMember(), WorldSession::GetPlayer(), GR_RIGHT_EOFFNOTE, GR_RIGHT_EPNOTE, GUILD_COMMAND_PUBLIC_NOTE, HandleRoster(), and SendCommandResult().

◆ HandleSetMOTD()

void Guild::HandleSetMOTD ( WorldSession session,
std::string_view  motd 
)
1273{
1274 if (m_motd == motd)
1275 return;
1276
1277 // Player must have rights to set MOTD
1278 if (!_HasRankRight(session->GetPlayer(), GR_RIGHT_SETMOTD))
1280 else
1281 {
1282 m_motd = motd;
1283
1284 sScriptMgr->OnGuildMOTDChanged(this, m_motd);
1285
1287 stmt->SetData(0, m_motd);
1288 stmt->SetData(1, m_id);
1289 CharacterDatabase.Execute(stmt);
1290
1292 }
1293}
@ GE_MOTD
Definition: Guild.h:152
@ GUILD_COMMAND_EDIT_MOTD
Definition: Guild.h:110
@ GR_RIGHT_SETMOTD
Definition: Guild.h:88
@ CHAR_UPD_GUILD_MOTD
Definition: CharacterDatabase.h:168

References _BroadcastEvent(), _HasRankRight(), CHAR_UPD_GUILD_MOTD, CharacterDatabase, ObjectGuid::Empty, ERR_GUILD_PERMISSIONS, GE_MOTD, WorldSession::GetPlayer(), GR_RIGHT_SETMOTD, GUILD_COMMAND_EDIT_MOTD, m_id, m_motd, SendCommandResult(), PreparedStatementBase::SetData(), and sScriptMgr.

◆ HandleSetRankInfo()

void Guild::HandleSetRankInfo ( WorldSession session,
uint8  rankId,
std::string_view  name,
uint32  rights,
uint32  moneyPerDay,
std::array< GuildBankRightsAndSlots, GUILD_BANK_MAX_TABS > const &  rightsAndSlots 
)
1384{
1385 // Only leader can modify ranks
1386 if (!_IsLeader(session->GetPlayer()))
1388 else if (RankInfo* rankInfo = GetRankInfo(rankId))
1389 {
1390 rankInfo->SetName(name);
1391 rankInfo->SetRights(rights);
1392 _SetRankBankMoneyPerDay(rankId, moneyPerDay);
1393
1394 for (auto& rightsAndSlot : rightsAndSlots)
1395 _SetRankBankTabRightsAndSlots(rankId, rightsAndSlot);
1396
1397 _BroadcastEvent(GE_RANK_UPDATED, ObjectGuid::Empty, std::to_string(rankId), rankInfo->GetName(), std::to_string(m_ranks.size()));
1398
1399 LOG_DEBUG("guild", "Changed RankName to '{}', rights to 0x{:08X}", rankInfo->GetName(), rights);
1400 }
1401}
@ GUILD_COMMAND_CHANGE_RANK
Definition: Guild.h:113
void _SetRankBankTabRightsAndSlots(uint8 rankId, GuildBankRightsAndSlots rightsAndSlots, bool saveToDB=true)
Definition: Guild.cpp:2509
void _SetRankBankMoneyPerDay(uint8 rankId, uint32 moneyPerDay)
Definition: Guild.cpp:2503

References _BroadcastEvent(), _IsLeader(), _SetRankBankMoneyPerDay(), _SetRankBankTabRightsAndSlots(), ObjectGuid::Empty, ERR_GUILD_PERMISSIONS, GE_RANK_UPDATED, WorldSession::GetPlayer(), GetRankInfo(), GUILD_COMMAND_CHANGE_RANK, LOG_DEBUG, m_ranks, and SendCommandResult().

Referenced by WorldSession::HandleGuildRankOpcode().

◆ HandleUpdateMemberRank()

void Guild::HandleUpdateMemberRank ( WorldSession session,
std::string_view  name,
bool  demote 
)
1570{
1571 Player* player = session->GetPlayer();
1573 // Player must have rights to promote
1574 if (!_HasRankRight(player, demote ? GR_RIGHT_DEMOTE : GR_RIGHT_PROMOTE))
1576 // Promoted player must be a member of guild
1577 else if (Member* member = GetMember(name))
1578 {
1579 // Player cannot promote himself
1580 if (member->IsSamePlayer(player->GetGUID()))
1581 {
1583 return;
1584 }
1585
1586 Member const* memberMe = GetMember(player->GetGUID());
1587 uint8 rankId = memberMe->GetRankId();
1588 if (demote)
1589 {
1590 // Player can demote only lower rank members
1591 if (member->IsRankNotLower(rankId))
1592 {
1593 SendCommandResult(session, type, ERR_GUILD_RANK_TOO_HIGH_S, name);
1594 return;
1595 }
1596 // Lowest rank cannot be demoted
1597 if (member->GetRankId() >= _GetLowestRankId())
1598 {
1599 SendCommandResult(session, type, ERR_GUILD_RANK_TOO_LOW_S, name);
1600 return;
1601 }
1602 }
1603 else
1604 {
1605 // Allow to promote only to lower rank than member's rank
1606 // member->GetRankId() + 1 is the highest rank that current player can promote to
1607 if (member->IsRankNotLower(rankId + 1))
1608 {
1609 SendCommandResult(session, type, ERR_GUILD_RANK_TOO_HIGH_S, name);
1610 return;
1611 }
1612 }
1613
1614 uint32 newRankId = member->GetRankId() + (demote ? 1 : -1);
1615 member->ChangeRank(newRankId);
1616 _LogEvent(demote ? GUILD_EVENT_LOG_DEMOTE_PLAYER : GUILD_EVENT_LOG_PROMOTE_PLAYER, player->GetGUID(), member->GetGUID(), newRankId);
1617 _BroadcastEvent(demote ? GE_DEMOTION : GE_PROMOTION, ObjectGuid::Empty, player->GetName(), member->GetName(), _GetRankName(newRankId));
1618 }
1619}
@ GE_PROMOTION
Definition: Guild.h:150
@ GE_DEMOTION
Definition: Guild.h:151
GuildCommandType
Definition: Guild.h:101
@ GUILD_COMMAND_PROMOTE
Definition: Guild.h:106
@ GUILD_COMMAND_DEMOTE
Definition: Guild.h:107
@ ERR_GUILD_RANK_TOO_LOW_S
Definition: Guild.h:137
@ ERR_GUILD_NAME_INVALID
Definition: Guild.h:128
@ GR_RIGHT_DEMOTE
Definition: Guild.h:87
@ GR_RIGHT_PROMOTE
Definition: Guild.h:86
@ GUILD_EVENT_LOG_PROMOTE_PLAYER
Definition: Guild.h:215
@ GUILD_EVENT_LOG_DEMOTE_PLAYER
Definition: Guild.h:216
std::string _GetRankName(uint8 rankId) const
Definition: Guild.cpp:2518

References _BroadcastEvent(), _GetLowestRankId(), _GetRankName(), _HasRankRight(), _LogEvent(), ObjectGuid::Empty, ERR_GUILD_NAME_INVALID, ERR_GUILD_PERMISSIONS, ERR_GUILD_RANK_TOO_HIGH_S, ERR_GUILD_RANK_TOO_LOW_S, GE_DEMOTION, GE_PROMOTION, Object::GetGUID(), GetMember(), WorldObject::GetName(), WorldSession::GetPlayer(), Guild::Member::GetRankId(), GR_RIGHT_DEMOTE, GR_RIGHT_PROMOTE, GUILD_COMMAND_DEMOTE, GUILD_COMMAND_PROMOTE, GUILD_EVENT_LOG_DEMOTE_PLAYER, GUILD_EVENT_LOG_PROMOTE_PLAYER, and SendCommandResult().

◆ LoadBankEventLogFromDB()

bool Guild::LoadBankEventLogFromDB ( Field fields)
1981{
1982 uint8 dbTabId = fields[1].Get<uint8>();
1983 bool isMoneyTab = (dbTabId == GUILD_BANK_MONEY_LOGS_TAB);
1984 if (dbTabId < _GetPurchasedTabsSize() || isMoneyTab)
1985 {
1986 uint8 tabId = isMoneyTab ? uint8(GUILD_BANK_MAX_TABS) : dbTabId;
1987 LogHolder<BankEventLogEntry>& bankLog = m_bankEventLog[tabId];
1988 if (bankLog.CanInsert())
1989 {
1990 ObjectGuid::LowType guid = fields[2].Get<uint32>();
1991 GuildBankEventLogTypes eventType = GuildBankEventLogTypes(fields[3].Get<uint8>());
1992 if (BankEventLogEntry::IsMoneyEvent(eventType))
1993 {
1994 if (!isMoneyTab)
1995 {
1996 LOG_ERROR("guild", "GuildBankEventLog ERROR: MoneyEvent(LogGuid: {}, Guild: {}) does not belong to money tab ({}), ignoring...", guid, m_id, dbTabId);
1997 return false;
1998 }
1999 }
2000 else if (isMoneyTab)
2001 {
2002 LOG_ERROR("guild", "GuildBankEventLog ERROR: non-money event (LogGuid: {}, Guild: {}) belongs to money tab, ignoring...", guid, m_id);
2003 return false;
2004 }
2005 bankLog.LoadEvent(
2006 m_id, // guild id
2007 guid, // guid
2008 time_t(fields[8].Get<uint32>()), // timestamp
2009 dbTabId, // tab id
2010 eventType, // event type
2011 ObjectGuid::Create<HighGuid::Player>(fields[4].Get<uint32>()), // player guid
2012 fields[5].Get<uint32>(), // item or money
2013 fields[6].Get<uint16>(), // itam stack count
2014 fields[7].Get<uint8>()); // dest tab id
2015 }
2016 }
2017 return true;
2018}
GuildBankEventLogTypes
Definition: Guild.h:199

References _GetPurchasedTabsSize(), Guild::LogHolder< Entry >::CanInsert(), Field::Get(), GUILD_BANK_MAX_TABS, GUILD_BANK_MONEY_LOGS_TAB, Guild::BankEventLogEntry::IsMoneyEvent(), Guild::LogHolder< Entry >::LoadEvent(), LOG_ERROR, m_bankEventLog, and m_id.

◆ LoadBankItemFromDB()

bool Guild::LoadBankItemFromDB ( Field fields)
2030{
2031 uint8 tabId = fields[12].Get<uint8>();
2032 if (tabId >= _GetPurchasedTabsSize())
2033 {
2034 LOG_ERROR("guild", "Invalid tab for item (GUID: {}, id: #{}) in guild bank, skipped.",
2035 fields[14].Get<uint32>(), fields[15].Get<uint32>());
2036 return false;
2037 }
2038 return m_bankTabs[tabId].LoadItemFromDB(fields);
2039}

References _GetPurchasedTabsSize(), Field::Get(), LOG_ERROR, and m_bankTabs.

◆ LoadBankRightFromDB()

void Guild::LoadBankRightFromDB ( Field fields)
1956{
1957 // tabId rights slots
1958 GuildBankRightsAndSlots rightsAndSlots(fields[1].Get<uint8>(), fields[3].Get<uint8>(), fields[4].Get<uint32>());
1959 // rankId
1960 _SetRankBankTabRightsAndSlots(fields[2].Get<uint8>(), rightsAndSlots, false);
1961}
Definition: Guild.h:266

References _SetRankBankTabRightsAndSlots().

◆ LoadBankTabFromDB()

void Guild::LoadBankTabFromDB ( Field fields)
2021{
2022 uint8 tabId = fields[1].Get<uint8>();
2023 if (tabId >= _GetPurchasedTabsSize())
2024 LOG_ERROR("guild", "Invalid tab (tabId: {}) in guild bank, skipped.", tabId);
2025 else
2026 m_bankTabs[tabId].LoadFromDB(fields);
2027}

References _GetPurchasedTabsSize(), Field::Get(), LOG_ERROR, and m_bankTabs.

◆ LoadEventLogFromDB()

bool Guild::LoadEventLogFromDB ( Field fields)
1964{
1965 if (m_eventLog.CanInsert())
1966 {
1967 m_eventLog.LoadEvent(
1968 m_id, // guild id
1969 fields[1].Get<uint32>(), // guid
1970 time_t(fields[6].Get<uint32>()), // timestamp
1971 GuildEventLogTypes(fields[2].Get<uint8>()), // event type
1972 ObjectGuid::Create<HighGuid::Player>(fields[3].Get<uint32>()), // player guid 1
1973 ObjectGuid::Create<HighGuid::Player>(fields[4].Get<uint32>()), // player guid 2
1974 fields[5].Get<uint8>()); // rank
1975 return true;
1976 }
1977 return false;
1978}
GuildEventLogTypes
Definition: Guild.h:212

References m_eventLog, and m_id.

◆ LoadFromDB()

bool Guild::LoadFromDB ( Field fields)
1901{
1902 m_id = fields[0].Get<uint32>();
1903 m_name = fields[1].Get<std::string>();
1904 m_leaderGuid = ObjectGuid::Create<HighGuid::Player>(fields[2].Get<uint32>());
1905 m_emblemInfo.LoadFromDB(fields);
1906 m_info = fields[8].Get<std::string>();
1907 m_motd = fields[9].Get<std::string>();
1908 m_createdDate = time_t(fields[10].Get<uint32>());
1909 m_bankMoney = fields[11].Get<uint64>();
1910
1911 uint8 purchasedTabs = uint8(fields[12].Get<uint64>());
1912 if (purchasedTabs > GUILD_BANK_MAX_TABS)
1913 purchasedTabs = GUILD_BANK_MAX_TABS;
1914
1915 m_bankTabs.clear();
1916 m_bankTabs.reserve(purchasedTabs);
1917 for (uint8 i = 0; i < purchasedTabs; ++i)
1918 m_bankTabs.emplace_back(m_id, i);
1919 return true;
1920}
std::uint64_t uint64
Definition: Define.h:106
void LoadFromDB(Field *fields)
Definition: Guild.cpp:692

References Field::Get(), GUILD_BANK_MAX_TABS, EmblemInfo::LoadFromDB(), m_bankMoney, m_bankTabs, m_createdDate, m_emblemInfo, m_id, m_info, m_leaderGuid, m_motd, and m_name.

Referenced by GuildMgr::LoadGuilds().

◆ LoadMemberFromDB()

bool Guild::LoadMemberFromDB ( Field fields)
1932{
1933 ObjectGuid::LowType lowguid = fields[1].Get<uint32>();
1934 ObjectGuid playerGuid(HighGuid::Player, lowguid);
1935
1936 auto [memberIt, isNew] = m_members.try_emplace(lowguid, m_id, playerGuid, fields[2].Get<uint8>());
1937 if (!isNew)
1938 {
1939 LOG_ERROR("guild", "Tried to add {} to guild '{}'. Member already exists.", playerGuid.ToString(), m_name);
1940 return false;
1941 }
1942
1943 Member& member = memberIt->second;
1944 if (!member.LoadFromDB(fields))
1945 {
1946 _DeleteMemberFromDB(lowguid);
1947 m_members.erase(memberIt);
1948 return false;
1949 }
1950
1951 sCharacterCache->UpdateCharacterGuildId(playerGuid, GetId());
1952 return true;
1953}

References _DeleteMemberFromDB(), Field::Get(), GetId(), Guild::Member::LoadFromDB(), LOG_ERROR, m_id, m_members, m_name, and sCharacterCache.

◆ LoadRankFromDB()

void Guild::LoadRankFromDB ( Field fields)
1923{
1924 RankInfo rankInfo(m_id);
1925
1926 rankInfo.LoadFromDB(fields);
1927
1928 m_ranks.push_back(rankInfo);
1929}

References Guild::RankInfo::LoadFromDB(), m_id, and m_ranks.

◆ MassInviteToEvent()

void Guild::MassInviteToEvent ( WorldSession session,
uint32  minLevel,
uint32  maxLevel,
uint32  minRank 
)
2143{
2144 uint32 count = 0;
2145
2147 data << uint32(count); // count placeholder
2148
2149 for (auto const& [guid, member] : m_members)
2150 {
2151 // not sure if needed, maybe client checks it as well
2152 if (count >= CALENDAR_MAX_INVITES)
2153 {
2154 if (Player* player = session->GetPlayer())
2155 sCalendarMgr->SendCalendarCommandResult(player->GetGUID(), CALENDAR_ERROR_INVITES_EXCEEDED);
2156 return;
2157 }
2158
2159 uint32 level = sCharacterCache->GetCharacterLevelByGuid(member.GetGUID());
2160
2161 if (member.GetGUID() != session->GetPlayer()->GetGUID() && level >= minLevel && level <= maxLevel && member.IsRankNotLower(minRank))
2162 {
2163 data.appendPackGUID(member.GetGUID().GetRawValue());
2164 data << uint8(0); // unk
2165 ++count;
2166 }
2167 }
2168
2169 data.put<uint32>(0, count);
2170
2171 session->SendPacket(&data);
2172}
@ CALENDAR_ERROR_INVITES_EXCEEDED
Definition: CalendarMgr.h:104
@ CALENDAR_MAX_INVITES
Definition: CalendarMgr.h:130
@ SMSG_CALENDAR_FILTER_GUILD
Definition: Opcodes.h:1110

References ByteBuffer::appendPackGUID(), CALENDAR_ERROR_INVITES_EXCEEDED, CALENDAR_MAX_INVITES, Object::GetGUID(), WorldSession::GetPlayer(), m_members, ByteBuffer::put(), sCalendarMgr, sCharacterCache, WorldSession::SendPacket(), and SMSG_CALENDAR_FILTER_GUILD.

◆ ModifyBankMoney()

bool Guild::ModifyBankMoney ( CharacterDatabaseTransaction  trans,
const uint64 amount,
bool  add 
)
inline
782{ return _ModifyBankMoney(trans, amount, add); }

References _ModifyBankMoney().

◆ OnPlayerStatusChange()

void Guild::OnPlayerStatusChange ( Player player,
uint32  flag,
bool  state 
)
1179{
1180 if (Member* member = GetMember(player->GetGUID()))
1181 {
1182 if (state)
1183 member->AddFlag(flag);
1184 else member->RemFlag(flag);
1185 }
1186}

References Object::GetGUID(), and GetMember().

◆ ResetTimes()

void Guild::ResetTimes ( )
2930{
2931 for (auto& [guid, member] : m_members)
2932 member.ResetValues();
2933
2935}
@ GE_BANK_TAB_AND_MONEY_UPDATED
Definition: Guild.h:168

References _BroadcastEvent(), ObjectGuid::Empty, GE_BANK_TAB_AND_MONEY_UPDATED, and m_members.

◆ SendBankLog()

void Guild::SendBankLog ( WorldSession session,
uint8  tabId 
) const
1793{
1794 // GUILD_BANK_MAX_TABS send by client for money log
1795 if (tabId < _GetPurchasedTabsSize() || tabId == GUILD_BANK_MAX_TABS)
1796 {
1797 std::list<BankEventLogEntry> const& bankEventLog = m_bankEventLog[tabId].GetGuildLog();
1798
1800 packet.Tab = tabId;
1801
1802 packet.Entry.reserve(bankEventLog.size());
1803 for (BankEventLogEntry const& entry : bankEventLog)
1804 entry.WritePacket(packet);
1805
1806 session->SendPacket(packet.Write());
1807 LOG_DEBUG("guild", "MSG_GUILD_BANK_LOG_QUERY [{}]", session->GetPlayerInfo());
1808 }
1809}
Definition: GuildPackets.h:546
uint8 Tab
Definition: GuildPackets.h:552
std::vector< GuildBankLogEntry > Entry
Definition: GuildPackets.h:553
WorldPacket const * Write() override
Definition: GuildPackets.cpp:385

References _GetPurchasedTabsSize(), WorldPackets::Guild::GuildBankLogQueryResults::Entry, WorldSession::GetPlayerInfo(), GUILD_BANK_MAX_TABS, LOG_DEBUG, m_bankEventLog, WorldSession::SendPacket(), WorldPackets::Guild::GuildBankLogQueryResults::Tab, and WorldPackets::Guild::GuildBankLogQueryResults::Write().

◆ SendBankTabData()

void Guild::SendBankTabData ( WorldSession session,
uint8  tabId,
bool  sendAllSlots 
) const
1812{
1813 if (tabId < _GetPurchasedTabsSize())
1814 _SendBankContent(session, tabId, sendAllSlots);
1815}
void _SendBankContent(WorldSession *session, uint8 tabId, bool sendAllSlots) const
Definition: Guild.cpp:2748

References _GetPurchasedTabsSize(), and _SendBankContent().

◆ SendBankTabsInfo()

void Guild::SendBankTabsInfo ( WorldSession session,
bool  showTabs = false 
)
1818{
1819 Member* member = GetMember(session->GetPlayer()->GetGUID());
1820 if (!member)
1821 return;
1822
1823 member->SubscribeToGuildBankUpdatePackets();
1824
1825 _SendBankList(session, 0, sendAllSlots);
1826}

References _SendBankList(), Object::GetGUID(), GetMember(), WorldSession::GetPlayer(), and Guild::Member::SubscribeToGuildBankUpdatePackets().

Referenced by WorldSession::HandleGuildBankerActivate().

◆ SendBankTabText()

void Guild::SendBankTabText ( WorldSession session,
uint8  tabId 
) const
1829{
1830 if (BankTab const* tab = GetBankTab(tabId))
1831 tab->SendText(this, session);
1832}

References GetBankTab().

◆ SendCommandResult()

void Guild::SendCommandResult ( WorldSession session,
GuildCommandType  type,
GuildCommandError  errCode,
std::string_view  param = {} 
)
static
115{
117 resultPacket.Command = type;
118 resultPacket.Result = errCode;
119 resultPacket.Name = param;
120 session->SendPacket(resultPacket.Write());
121
122 LOG_DEBUG("guild", "SMSG_GUILD_COMMAND_RESULT [{}]: Type: {}, code: {}, param: {}", session->GetPlayerInfo(), type, errCode, resultPacket.Name);
123}
Definition: GuildPackets.h:154
int32 Command
Definition: GuildPackets.h:162
std::string Name
Definition: GuildPackets.h:160
WorldPacket const * Write() override
Definition: GuildPackets.cpp:81
int32 Result
Definition: GuildPackets.h:161

References WorldPackets::Guild::GuildCommandResult::Command, WorldSession::GetPlayerInfo(), LOG_DEBUG, WorldPackets::Guild::GuildCommandResult::Name, WorldPackets::Guild::GuildCommandResult::Result, WorldSession::SendPacket(), and WorldPackets::Guild::GuildCommandResult::Write().

Referenced by WorldSession::HandleGuildBankerActivate(), WorldSession::HandleGuildRosterOpcode(), HandleInviteMember(), HandleLeaveMember(), HandleMemberDepositMoney(), WorldSession::HandleOfferPetitionOpcode(), WorldSession::HandlePetitionBuyOpcode(), WorldSession::HandlePetitionRenameOpcode(), WorldSession::HandlePetitionSignOpcode(), HandleRemoveMember(), HandleSetLeader(), HandleSetMemberNote(), HandleSetMOTD(), HandleSetRankInfo(), WorldSession::HandleTurnInPetitionOpcode(), and HandleUpdateMemberRank().

◆ SendEventLog()

void Guild::SendEventLog ( WorldSession session) const
1779{
1780 std::list<EventLogEntry> const& eventLog = m_eventLog.GetGuildLog();
1781
1783 packet.Entry.reserve(eventLog.size());
1784
1785 for (EventLogEntry const& entry : eventLog)
1786 entry.WritePacket(packet);
1787
1788 session->SendPacket(packet.Write());
1789 LOG_DEBUG("guild", "MSG_GUILD_EVENT_LOG_QUERY [{}]", session->GetPlayerInfo());
1790}
std::vector< GuildEventEntry > Entry
Definition: GuildPackets.h:238
WorldPacket const * Write() override
Definition: GuildPackets.cpp:144

References WorldPackets::Guild::GuildEventLogQueryResults::Entry, WorldSession::GetPlayerInfo(), LOG_DEBUG, m_eventLog, WorldSession::SendPacket(), and WorldPackets::Guild::GuildEventLogQueryResults::Write().

◆ SendInfo()

void Guild::SendInfo ( WorldSession session) const
1767{
1769 guildInfo.GuildName = m_name;
1770 guildInfo.CreateDate = m_createdDate;
1771 guildInfo.NumMembers = int32(m_members.size());
1772 guildInfo.NumAccounts = m_accountsNumber;
1773
1774 session->SendPacket(guildInfo.Write());
1775 LOG_DEBUG("guild", "SMSG_GUILD_INFO [{}]", session->GetPlayerInfo());
1776}
Definition: GuildPackets.h:85
time_t CreateDate
Definition: GuildPackets.h:92
int32 NumAccounts
Definition: GuildPackets.h:94
WorldPacket const * Write() override
Definition: GuildPackets.cpp:50
int32 NumMembers
Definition: GuildPackets.h:93
std::string GuildName
Definition: GuildPackets.h:91

References WorldPackets::Guild::GuildInfoResponse::CreateDate, WorldSession::GetPlayerInfo(), WorldPackets::Guild::GuildInfoResponse::GuildName, LOG_DEBUG, m_accountsNumber, m_createdDate, m_members, m_name, WorldPackets::Guild::GuildInfoResponse::NumAccounts, WorldPackets::Guild::GuildInfoResponse::NumMembers, WorldSession::SendPacket(), and WorldPackets::Guild::GuildInfoResponse::Write().

◆ SendLoginInfo()

void Guild::SendLoginInfo ( WorldSession session)
1879{
1881 motd.Type = GE_MOTD;
1882 motd.Params.emplace_back(m_motd);
1883 session->SendPacket(motd.Write());
1884
1885 LOG_DEBUG("guild", "SMSG_GUILD_EVENT [{}] MOTD", session->GetPlayerInfo());
1886
1887 Player* player = session->GetPlayer();
1888
1889 HandleRoster(session);
1890 _BroadcastEvent(GE_SIGNED_ON, player->GetGUID(), player->GetName());
1891
1892 if (Member* member = GetMember(player->GetGUID()))
1893 {
1894 member->SetStats(player);
1895 member->AddFlag(GUILDMEMBER_STATUS_ONLINE);
1896 }
1897}
@ GE_SIGNED_ON
Definition: Guild.h:162
@ GUILDMEMBER_STATUS_ONLINE
Definition: Guild.h:234
boost::container::static_vector< std::string_view, 3 > Params
Definition: GuildPackets.h:210

References _BroadcastEvent(), GE_MOTD, GE_SIGNED_ON, Object::GetGUID(), GetMember(), WorldObject::GetName(), WorldSession::GetPlayer(), WorldSession::GetPlayerInfo(), GUILDMEMBER_STATUS_ONLINE, HandleRoster(), LOG_DEBUG, m_motd, WorldPackets::Guild::GuildEvent::Params, WorldSession::SendPacket(), WorldPackets::Guild::GuildEvent::Type, and WorldPackets::Guild::GuildEvent::Write().

Referenced by AddMember(), and WorldSession::HandlePlayerLoginFromDB().

◆ SendMoneyInfo()

void Guild::SendMoneyInfo ( WorldSession session) const
1864{
1865 Member const* member = GetMember(session->GetPlayer()->GetGUID());
1866 if (!member)
1867 return;
1868
1869 int32 amount = _GetMemberRemainingMoney(*member);
1870
1872 packet.RemainingWithdrawMoney = amount;
1873 session->SendPacket(packet.Write());
1874
1875 LOG_DEBUG("guild", "MSG_GUILD_BANK_MONEY_WITHDRAWN [{}] Money: {}", session->GetPlayerInfo(), amount);
1876}
int32 RemainingWithdrawMoney
Definition: GuildPackets.h:442
WorldPacket const * Write() override
Definition: GuildPackets.cpp:272

References _GetMemberRemainingMoney(), Object::GetGUID(), GetMember(), WorldSession::GetPlayer(), WorldSession::GetPlayerInfo(), LOG_DEBUG, WorldPackets::Guild::GuildBankRemainingWithdrawMoney::RemainingWithdrawMoney, WorldSession::SendPacket(), and WorldPackets::Guild::GuildBankRemainingWithdrawMoney::Write().

◆ SendPermissions()

void Guild::SendPermissions ( WorldSession session)
1835{
1836 Member* member = GetMember(session->GetPlayer()->GetGUID());
1837 if (!member)
1838 return;
1839
1840 // We are unsubscribing here since it is the only reliable way to handle /reload from player as
1841 // GuildPermissionsQuery is sent on each reload, and we don't want to send partial changes while client
1842 // doesn't know the full state
1843 member->UnsubscribeFromGuildBankUpdatePackets();
1844
1845 uint8 rankId = member->GetRankId();
1846
1848 queryResult.RankID = rankId;
1849 queryResult.WithdrawGoldLimit = _GetRankBankMoneyPerDay(rankId);
1850 queryResult.Flags = _GetRankRights(rankId);
1851 queryResult.NumTabs = _GetPurchasedTabsSize();
1852
1853 for (uint8 tabId = 0; tabId < GUILD_BANK_MAX_TABS; ++tabId)
1854 {
1855 queryResult.Tab[tabId].Flags = _GetRankBankTabRights(rankId, tabId);
1856 queryResult.Tab[tabId].WithdrawItemLimit = _GetMemberRemainingSlots(*member, tabId);
1857 }
1858
1859 session->SendPacket(queryResult.Write());
1860 LOG_DEBUG("guild", "MSG_GUILD_PERMISSIONS [{}] Rank: {}", session->GetPlayerInfo(), rankId);
1861}
int32 Flags
Definition: GuildPackets.h:264
WorldPacket const * Write() override
Definition: GuildPackets.cpp:164
uint32 RankID
Definition: GuildPackets.h:265
int32 WithdrawGoldLimit
Definition: GuildPackets.h:263
int8 NumTabs
Definition: GuildPackets.h:262
std::array< GuildRankTabPermissions, GUILD_BANK_MAX_TABS > Tab
Definition: GuildPackets.h:266

References _GetMemberRemainingSlots(), _GetPurchasedTabsSize(), _GetRankBankMoneyPerDay(), _GetRankBankTabRights(), _GetRankRights(), WorldPackets::Guild::GuildPermissionsQueryResults::Flags, Object::GetGUID(), GetMember(), WorldSession::GetPlayer(), WorldSession::GetPlayerInfo(), Guild::Member::GetRankId(), GUILD_BANK_MAX_TABS, LOG_DEBUG, WorldPackets::Guild::GuildPermissionsQueryResults::NumTabs, WorldPackets::Guild::GuildPermissionsQueryResults::RankID, WorldSession::SendPacket(), WorldPackets::Guild::GuildPermissionsQueryResults::Tab, Guild::Member::UnsubscribeFromGuildBankUpdatePackets(), WorldPackets::Guild::GuildPermissionsQueryResults::WithdrawGoldLimit, and WorldPackets::Guild::GuildPermissionsQueryResults::Write().

Referenced by HandleBuyBankTab().

◆ SendSaveEmblemResult()

void Guild::SendSaveEmblemResult ( WorldSession session,
GuildEmblemError  errCode 
)
static
126{
128 saveResponse.Error = int32(errCode);
129 session->SendPacket(saveResponse.Write());
130
131 LOG_DEBUG("guild", "MSG_SAVE_GUILD_EMBLEM [{}] Code: {}", session->GetPlayerInfo(), errCode);
132}
Definition: GuildPackets.h:614
WorldPacket const * Write() override
Definition: GuildPackets.cpp:453
int32 Error
Definition: GuildPackets.h:620

References WorldPackets::Guild::PlayerSaveGuildEmblem::Error, WorldSession::GetPlayerInfo(), LOG_DEBUG, WorldSession::SendPacket(), and WorldPackets::Guild::PlayerSaveGuildEmblem::Write().

Referenced by WorldSession::HandleSaveGuildEmblemOpcode(), and HandleSetEmblem().

◆ SetBankTabText()

void Guild::SetBankTabText ( uint8  tabId,
std::string_view  text 
)
2372{
2373 if (BankTab* pTab = GetBankTab(tabId))
2374 {
2375 pTab->SetText(text);
2376 pTab->SendText(this, nullptr);
2377 }
2378}

References GetBankTab().

◆ SetName()

bool Guild::SetName ( std::string_view const &  name)
1189{
1190 if (m_name == name || name.empty() || name.length() > 24 || !ObjectMgr::IsValidCharterName(name))
1191 {
1192 return false;
1193 }
1194
1195 m_name = name;
1197 stmt->SetData(0, m_name);
1198 stmt->SetData(1, GetId());
1199 CharacterDatabase.Execute(stmt);
1200 return true;
1201}
@ CHAR_UPD_GUILD_NAME
Definition: CharacterDatabase.h:142
static bool IsValidCharterName(std::string_view name)
Definition: ObjectMgr.cpp:8413

References CHAR_UPD_GUILD_NAME, CharacterDatabase, GetId(), ObjectMgr::IsValidCharterName(), m_name, and PreparedStatementBase::SetData().

Referenced by guild_commandscript::HandleGuildRenameCommand().

◆ SwapItems()

void Guild::SwapItems ( Player player,
uint8  tabId,
uint8  slotId,
uint8  destTabId,
uint8  destSlotId,
uint32  splitedAmount 
)
2344{
2345 if (tabId >= _GetPurchasedTabsSize() || slotId >= GUILD_BANK_MAX_SLOTS ||
2346 destTabId >= _GetPurchasedTabsSize() || destSlotId >= GUILD_BANK_MAX_SLOTS)
2347 return;
2348
2349 if (tabId == destTabId && slotId == destSlotId)
2350 return;
2351
2352 BankMoveItemData from(this, player, tabId, slotId);
2353 BankMoveItemData to(this, player, destTabId, destSlotId);
2354 _MoveItems(&from, &to, splitedAmount);
2355}
void _MoveItems(MoveItemData *pSrc, MoveItemData *pDest, uint32 splitedAmount)
Definition: Guild.cpp:2651

References _GetPurchasedTabsSize(), _MoveItems(), and GUILD_BANK_MAX_SLOTS.

Referenced by WorldSession::HandleGuildBankSwapItems().

◆ SwapItemsWithInventory()

void Guild::SwapItemsWithInventory ( Player player,
bool  toChar,
uint8  tabId,
uint8  slotId,
uint8  playerBag,
uint8  playerSlotId,
uint32  splitedAmount 
)
2358{
2359 if ((slotId >= GUILD_BANK_MAX_SLOTS && slotId != NULL_SLOT) || tabId >= _GetPurchasedTabsSize())
2360 return;
2361
2362 BankMoveItemData bankData(this, player, tabId, slotId);
2363 PlayerMoveItemData charData(this, player, playerBag, playerSlotId);
2364 if (toChar)
2365 _MoveItems(&bankData, &charData, splitedAmount);
2366 else
2367 _MoveItems(&charData, &bankData, splitedAmount);
2368}
@ NULL_SLOT
Definition: Item.h:41

References _GetPurchasedTabsSize(), _MoveItems(), GUILD_BANK_MAX_SLOTS, and NULL_SLOT.

Referenced by WorldSession::HandleGuildBankSwapItems().

◆ UpdateMemberData()

void Guild::UpdateMemberData ( Player player,
uint8  dataid,
uint32  value 
)
1159{
1160 if (Member* member = GetMember(player->GetGUID()))
1161 {
1162 switch (dataid)
1163 {
1165 member->SetZoneID(value);
1166 break;
1168 member->SetLevel(value);
1169 break;
1170 default:
1171 LOG_ERROR("guild", "Guild::UpdateMemberData: Called with incorrect DATAID {} (value {})", dataid, value);
1172 return;
1173 }
1174 //HandleRoster();
1175 }
1176}
@ GUILD_MEMBER_DATA_LEVEL
Definition: Guild.h:62
@ GUILD_MEMBER_DATA_ZONEID
Definition: Guild.h:61

References Object::GetGUID(), GetMember(), GUILD_MEMBER_DATA_LEVEL, GUILD_MEMBER_DATA_ZONEID, and LOG_ERROR.

◆ Validate()

bool Guild::Validate ( )
2043{
2044 // Validate ranks data
2045 // GUILD RANKS represent a sequence starting from 0 = GUILD_MASTER (ALL PRIVILEGES) to max 9 (lowest privileges).
2046 // The lower rank id is considered higher rank - so promotion does rank-- and demotion does rank++
2047 // Between ranks in sequence cannot be gaps - so 0, 1, 2, 4 is impossible
2048 // Min ranks count is 5 and max is 10.
2049 bool broken_ranks = false;
2050 uint8 ranks = _GetRanksSize();
2051 if (ranks < GUILD_RANKS_MIN_COUNT || ranks > GUILD_RANKS_MAX_COUNT)
2052 {
2053 LOG_ERROR("guild", "Guild {} has invalid number of ranks, creating new...", m_id);
2054 broken_ranks = true;
2055 }
2056 else
2057 {
2058 for (uint8 rankId = 0; rankId < ranks; ++rankId)
2059 {
2060 RankInfo* rankInfo = GetRankInfo(rankId);
2061 if (rankInfo->GetId() != rankId)
2062 {
2063 LOG_ERROR("guild", "Guild {} has broken rank id {}, creating default set of ranks...", m_id, rankId);
2064 broken_ranks = true;
2065 }
2066 else
2067 {
2068 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
2069 rankInfo->CreateMissingTabsIfNeeded(_GetPurchasedTabsSize(), trans, true);
2070 CharacterDatabase.CommitTransaction(trans);
2071 }
2072 }
2073 }
2074
2075 if (broken_ranks)
2076 {
2077 m_ranks.clear();
2079 }
2080
2081 // Validate members' data
2082 for (auto& [guid, member] : m_members)
2083 if (member.GetRankId() > _GetRanksSize())
2084 member.ChangeRank(_GetLowestRankId());
2085
2086 // Repair the structure of the guild.
2087 // If the guildmaster doesn't exist or isn't member of the guild
2088 // attempt to promote another member.
2089 Member* pLeader = GetMember(m_leaderGuid);
2090 if (!pLeader)
2091 {
2093 // If no more members left, disband guild
2094 if (m_members.empty())
2095 {
2096 Disband();
2097 return false;
2098 }
2099 }
2100 else if (!pLeader->IsRank(GR_GUILDMASTER))
2101 _SetLeaderGUID(*pLeader);
2102
2103 // Check config if multiple guildmasters are allowed
2104 if (!sConfigMgr->GetOption<bool>("Guild.AllowMultipleGuildMaster", 0))
2105 for (auto& [guid, member] : m_members)
2106 if ((member.GetRankId() == GR_GUILDMASTER) && !member.IsSamePlayer(m_leaderGuid))
2107 member.ChangeRank(GR_OFFICER);
2108
2110 return true;
2111}
#define DEFAULT_LOCALE
Definition: Common.h:79

References _CreateDefaultGuildRanks(), _GetLowestRankId(), _GetPurchasedTabsSize(), _GetRanksSize(), _SetLeaderGUID(), _UpdateAccountsNumber(), CharacterDatabase, Guild::RankInfo::CreateMissingTabsIfNeeded(), DEFAULT_LOCALE, DeleteMember(), Disband(), Guild::RankInfo::GetId(), GetMember(), GetRankInfo(), GR_GUILDMASTER, GR_OFFICER, GUILD_RANKS_MAX_COUNT, Guild::Member::IsRank(), LOG_ERROR, m_id, m_leaderGuid, m_members, m_ranks, and sConfigMgr.

Referenced by GuildMgr::LoadGuilds().

Member Data Documentation

◆ m_accountsNumber

uint32 Guild::m_accountsNumber
protected

Referenced by _UpdateAccountsNumber(), and SendInfo().

◆ m_bankEventLog

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

◆ m_bankMoney

◆ m_bankTabs

◆ m_createdDate

time_t Guild::m_createdDate
protected

◆ m_emblemInfo

EmblemInfo Guild::m_emblemInfo
protected

◆ m_eventLog

LogHolder<EventLogEntry> Guild::m_eventLog
protected

◆ m_id

◆ m_info

std::string Guild::m_info
protected

◆ m_leaderGuid

◆ m_members

◆ m_motd

std::string Guild::m_motd
protected

◆ m_name

◆ m_ranks