TrinityCore
Guild Class Reference

#include <Guild.h>

Classes

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

Public Member Functions

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

Static Public Member Functions

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

Protected Attributes

ObjectGuid::LowType m_id
 
std::string m_name
 
ObjectGuid m_leaderGuid
 
std::string m_motd
 
std::string m_info
 
time_t m_createdDate
 
EmblemInfo m_emblemInfo
 
uint32 m_accountsNumber
 
uint64 m_bankMoney
 
Ranks m_ranks
 
Members m_members
 
BankTabs m_bankTabs
 
LogHolderm_eventLog
 
LogHolderm_bankEventLog [GUILD_BANK_MAX_TABS+1]
 
LogHolderm_newsLog
 
GuildAchievementMgr m_achievementMgr
 

Private Types

typedef std::list< LogEntry * > GuildLog
 
typedef std::unordered_map< ObjectGuid, Member * > Members
 
typedef std::vector< RankInfoRanks
 
typedef std::vector< BankTab * > BankTabs
 

Private Member Functions

uint8 _GetRanksSize () const
 
RankInfo const * GetRankInfo (uint8 rankId) const
 
RankInfoGetRankInfo (uint8 rankId)
 
bool _HasRankRight (Player const *player, uint32 right) const
 
uint8 _GetLowestRankId () const
 
uint8 _GetPurchasedTabsSize () const
 
BankTabGetBankTab (uint8 tabId)
 
BankTab const * GetBankTab (uint8 tabId) const
 
Member const * GetMember (ObjectGuid const &guid) const
 
MemberGetMember (ObjectGuid const &guid)
 
MemberGetMember (std::string const &name)
 
void _CreateLogHolders ()
 
void _CreateNewBankTab ()
 
void _CreateDefaultGuildRanks (CharacterDatabaseTransaction &trans, LocaleConstant loc)
 
bool _CreateRank (CharacterDatabaseTransaction &trans, std::string const &name, uint32 rights)
 
void _UpdateAccountsNumber ()
 
bool _IsLeader (Player *player) const
 
void _DeleteBankItems (CharacterDatabaseTransaction &trans, bool removeItemsFromDB=false)
 
bool _ModifyBankMoney (CharacterDatabaseTransaction &trans, uint64 amount, bool add)
 
void _SetLeader (CharacterDatabaseTransaction &trans, Member *leader)
 
void _SetRankBankMoneyPerDay (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
 
uint32 _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
 
int64 _GetMemberRemainingMoney (Member const *member) const
 
void _UpdateMemberWithdrawSlots (CharacterDatabaseTransaction &trans, ObjectGuid guid, uint8 tabId)
 
bool _MemberHasTabRights (ObjectGuid guid, uint8 tabId, int32 rights) const
 
void _LogEvent (GuildEventLogTypes eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2=UI64LIT(0), uint8 newRank=0)
 
void _LogBankEvent (CharacterDatabaseTransaction &trans, GuildBankEventLogTypes eventType, uint8 tabId, ObjectGuid::LowType playerGuid, uint64 itemOrMoney, uint16 itemStackCount=0, uint8 destTabId=0)
 
Item_GetItem (uint8 tabId, uint8 slotId) const
 
void _RemoveItem (CharacterDatabaseTransaction &trans, uint8 tabId, uint8 slotId)
 
void _MoveItems (MoveItemData *pSrc, MoveItemData *pDest, uint32 splitedAmount) const
 
void _SendBankContentUpdate (MoveItemData *pSrc, MoveItemData *pDest) const
 
void _SendBankContentUpdate (uint8 tabId, SlotIds slots) const
 
void SendGuildRanksUpdate (ObjectGuid setterGuid, ObjectGuid targetGuid, uint32 rank)
 

Static Private Member Functions

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

Member Typedef Documentation

◆ BankTabs

typedef std::vector<BankTab*> Guild::BankTabs
private

◆ GuildLog

typedef std::list<LogEntry*> Guild::GuildLog
private

◆ Members

typedef std::unordered_map<ObjectGuid, Member*> Guild::Members
private

◆ Ranks

typedef std::vector<RankInfo> Guild::Ranks
private

Constructor & Destructor Documentation

◆ Guild()

Guild::Guild ( )
1108  :
1109  m_id(UI64LIT(0)),
1110  m_leaderGuid(),
1111  m_createdDate(0),
1112  m_accountsNumber(0),
1113  m_bankMoney(0),
1114  m_eventLog(nullptr),
1115  m_newsLog(nullptr),
1116  m_achievementMgr(this)
1117 {
1118  memset(&m_bankEventLog, 0, (GUILD_BANK_MAX_TABS + 1) * sizeof(LogHolder*));
1119 }
LogHolder * m_eventLog
Definition: Guild.h:863
LogHolder * m_bankEventLog[GUILD_BANK_MAX_TABS+1]
Definition: Guild.h:864
uint32 m_accountsNumber
Definition: Guild.h:855
#define UI64LIT(N)
Definition: Define.h:140
time_t m_createdDate
Definition: Guild.h:852
Definition: Guild.h:48
ObjectGuid m_leaderGuid
Definition: Guild.h:849
ObjectGuid::LowType m_id
Definition: Guild.h:847
GuildAchievementMgr m_achievementMgr
Definition: Guild.h:866
uint64 m_bankMoney
Definition: Guild.h:856
LogHolder * m_newsLog
Definition: Guild.h:865

◆ ~Guild()

Guild::~Guild ( )
1122 {
1123  CharacterDatabaseTransaction temp(nullptr);
1124  _DeleteBankItems(temp);
1125 
1126  // Cleanup
1127  delete m_eventLog;
1128  m_eventLog = nullptr;
1129  delete m_newsLog;
1130  m_newsLog = nullptr;
1131 
1132  for (uint8 tabId = 0; tabId <= GUILD_BANK_MAX_TABS; ++tabId)
1133  {
1134  delete m_bankEventLog[tabId];
1135  m_bankEventLog[tabId] = nullptr;
1136  }
1137 
1138  for (auto itr = m_members.begin(); itr != m_members.end(); ++itr)
1139  {
1140  delete itr->second;
1141  itr->second = nullptr;
1142  }
1143 }
LogHolder * m_eventLog
Definition: Guild.h:863
LogHolder * m_bankEventLog[GUILD_BANK_MAX_TABS+1]
Definition: Guild.h:864
void _DeleteBankItems(CharacterDatabaseTransaction &trans, bool removeItemsFromDB=false)
Definition: Guild.cpp:2997
Definition: Guild.h:48
Members m_members
Definition: Guild.h:859
uint8_t uint8
Definition: Define.h:154
LogHolder * m_newsLog
Definition: Guild.h:865
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:72
+ Here is the call graph for this function:

Member Function Documentation

◆ _CreateDefaultGuildRanks()

void Guild::_CreateDefaultGuildRanks ( CharacterDatabaseTransaction trans,
LocaleConstant  loc 
)
private
2932 {
2933  ASSERT(trans);
2934 
2936  stmt->setUInt64(0, m_id);
2937  trans->Append(stmt);
2938 
2939  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_RIGHTS);
2940  stmt->setUInt64(0, m_id);
2941  trans->Append(stmt);
2942 
2943  _CreateRank(trans, sObjectMgr->GetTrinityString(LANG_GUILD_MASTER, loc), GR_RIGHT_ALL);
2944  _CreateRank(trans, sObjectMgr->GetTrinityString(LANG_GUILD_OFFICER, loc), GR_RIGHT_ALL);
2948 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: Guild.h:105
#define sObjectMgr
Definition: ObjectMgr.h:1880
Definition: DatabaseEnvFwd.h:40
Definition: CharacterDatabase.h:215
Definition: CharacterDatabase.h:225
Definition: Language.h:764
Definition: Guild.h:84
Definition: Language.h:765
bool _CreateRank(CharacterDatabaseTransaction &trans, std::string const &name, uint32 rights)
Definition: Guild.cpp:2950
ObjectGuid::LowType m_id
Definition: Guild.h:847
Definition: Language.h:766
Definition: Language.h:763
Definition: Guild.h:85
#define ASSERT
Definition: Errors.h:61
Definition: Language.h:767
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _CreateLogHolders()

void Guild::_CreateLogHolders ( )
private
2900 {
2901  m_eventLog = new LogHolder(sWorld->getIntConfig(CONFIG_GUILD_EVENT_LOG_COUNT));
2902  m_newsLog = new LogHolder(sWorld->getIntConfig(CONFIG_GUILD_NEWS_LOG_COUNT));
2903  for (uint8 tabId = 0; tabId <= GUILD_BANK_MAX_TABS; ++tabId)
2904  m_bankEventLog[tabId] = new LogHolder(sWorld->getIntConfig(CONFIG_GUILD_BANK_EVENT_LOG_COUNT));
2905 }
Definition: World.h:347
LogHolder * m_eventLog
Definition: Guild.h:863
LogHolder * m_bankEventLog[GUILD_BANK_MAX_TABS+1]
Definition: Guild.h:864
#define sWorld
Definition: World.h:926
Definition: World.h:346
Definition: Guild.h:48
Definition: World.h:348
uint8_t uint8
Definition: Define.h:154
LogHolder * m_newsLog
Definition: Guild.h:865
+ Here is the caller graph for this function:

◆ _CreateNewBankTab()

void Guild::_CreateNewBankTab ( )
private
2908 {
2909  uint8 tabId = _GetPurchasedTabsSize(); // Next free id
2910  m_bankTabs.push_back(new BankTab(m_id, tabId));
2911 
2912  CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
2913 
2915  stmt->setUInt64(0, m_id);
2916  stmt->setUInt8 (1, tabId);
2917  trans->Append(stmt);
2918 
2919  stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD_BANK_TAB);
2920  stmt->setUInt64(0, m_id);
2921  stmt->setUInt8 (1, tabId);
2922  trans->Append(stmt);
2923 
2924  ++tabId;
2925  for (auto itr = m_ranks.begin(); itr != m_ranks.end(); ++itr)
2926  (*itr).CreateMissingTabsIfNeeded(tabId, trans, false);
2927 
2928  CharacterDatabase.CommitTransaction(trans);
2929 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
BankTabs m_bankTabs
Definition: Guild.h:860
Definition: CharacterDatabase.h:217
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:100
Definition: DatabaseEnvFwd.h:40
Ranks m_ranks
Definition: Guild.h:858
uint8 _GetPurchasedTabsSize() const
Definition: Guild.h:876
ObjectGuid::LowType m_id
Definition: Guild.h:847
Definition: CharacterDatabase.h:218
uint8_t uint8
Definition: Define.h:154
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:72
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _CreateRank()

bool Guild::_CreateRank ( CharacterDatabaseTransaction trans,
std::string const &  name,
uint32  rights 
)
private
2951 {
2952  uint8 newRankId = _GetRanksSize();
2953  if (newRankId >= GUILD_RANKS_MAX_COUNT)
2954  return false;
2955 
2956  // Ranks represent sequence 0, 1, 2, ... where 0 means guildmaster
2957  RankInfo info(m_id, newRankId, name, rights, 0);
2958  m_ranks.push_back(info);
2959 
2960  bool const isInTransaction = bool(trans);
2961  if (!isInTransaction)
2962  trans = CharacterDatabase.BeginTransaction();
2963 
2964  info.CreateMissingTabsIfNeeded(_GetPurchasedTabsSize(), trans);
2965  info.SaveToDB(trans);
2966 
2967  if (!isInTransaction)
2968  CharacterDatabase.CommitTransaction(trans);
2969 
2970  return true;
2971 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Ranks m_ranks
Definition: Guild.h:858
uint8 _GetPurchasedTabsSize() const
Definition: Guild.h:876
ObjectGuid::LowType m_id
Definition: Guild.h:847
uint8_t uint8
Definition: Define.h:154
Definition: Guild.h:53
uint8 _GetRanksSize() const
Definition: Guild.h:869
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _DeleteBankItems()

void Guild::_DeleteBankItems ( CharacterDatabaseTransaction trans,
bool  removeItemsFromDB = false 
)
private
2998 {
2999  for (uint8 tabId = 0; tabId < _GetPurchasedTabsSize(); ++tabId)
3000  {
3001  m_bankTabs[tabId]->Delete(trans, removeItemsFromDB);
3002  delete m_bankTabs[tabId];
3003  m_bankTabs[tabId] = nullptr;
3004  }
3005  m_bankTabs.clear();
3006 }
BankTabs m_bankTabs
Definition: Guild.h:860
uint8 _GetPurchasedTabsSize() const
Definition: Guild.h:876
uint8_t uint8
Definition: Define.h:154
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _DeleteMemberFromDB()

void Guild::_DeleteMemberFromDB ( CharacterDatabaseTransaction trans,
ObjectGuid::LowType  lowguid 
)
staticprivate
2892 {
2894  stmt->setUInt64(0, lowguid);
2895  CharacterDatabase.ExecuteOrAppend(trans, stmt);
2896 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: CharacterDatabase.h:212
Definition: DatabaseEnvFwd.h:40
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _DoItemsMove()

InventoryResult Guild::_DoItemsMove ( MoveItemData pSrc,
MoveItemData pDest,
bool  sendError,
uint32  splitedAmount = 0 
)
staticprivate
3263 {
3264  Item* pDestItem = pDest->GetItem();
3265  bool swap = (pDestItem != nullptr);
3266 
3267  Item* pSrcItem = pSrc->GetItem(splitedAmount != 0);
3268  // 1. Can store source item in destination
3269  InventoryResult destResult = pDest->CanStore(pSrcItem, swap, sendError);
3270  if (destResult != EQUIP_ERR_OK)
3271  return destResult;
3272 
3273  // 2. Can store destination item in source
3274  if (swap)
3275  {
3276  InventoryResult srcResult = pSrc->CanStore(pDestItem, true, true);
3277  if (srcResult != EQUIP_ERR_OK)
3278  return srcResult;
3279  }
3280 
3281  // GM LOG (@todo move to scripts)
3282  pDest->LogAction(pSrc);
3283  if (swap)
3284  pSrc->LogAction(pDest);
3285 
3286  CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
3287  // 3. Log bank events
3288  pDest->LogBankEvent(trans, pSrc, pSrcItem->GetCount());
3289  if (swap)
3290  pSrc->LogBankEvent(trans, pDest, pDestItem->GetCount());
3291 
3292  // 4. Remove item from source
3293  pSrc->RemoveItem(trans, pDest, splitedAmount);
3294 
3295  // 5. Remove item from destination
3296  if (swap)
3297  pDest->RemoveItem(trans, pSrc);
3298 
3299  // 6. Store item in destination
3300  pDest->StoreItem(trans, pSrcItem);
3301 
3302  // 7. Store item in source
3303  if (swap)
3304  pSrc->StoreItem(trans, pDestItem);
3305 
3306  CharacterDatabase.CommitTransaction(trans);
3307  return EQUIP_ERR_OK;
3308 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
InventoryResult
Definition: ItemDefines.h:23
Definition: Item.h:169
uint32 GetCount() const
Definition: Item.h:264
Definition: ItemDefines.h:25
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:72
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _GetItem()

Item * Guild::_GetItem ( uint8  tabId,
uint8  slotId 
) const
inlineprivate
3185 {
3186  if (BankTab const* tab = GetBankTab(tabId))
3187  return tab->GetItem(slotId);
3188  return nullptr;
3189 }
BankTab * GetBankTab(uint8 tabId)
Definition: Guild.h:877
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _GetLowestRankId()

uint8 Guild::_GetLowestRankId ( ) const
inlineprivate
874 { return uint8(m_ranks.size() - 1); }
Ranks m_ranks
Definition: Guild.h:858
uint8_t uint8
Definition: Define.h:154
+ Here is the caller graph for this function:

◆ _GetMemberRemainingMoney()

int64 Guild::_GetMemberRemainingMoney ( Member const *  member) const
inlineprivate
3117 {
3118  if (member)
3119  {
3120  uint8 rankId = member->GetRankId();
3121  if (rankId == GR_GUILDMASTER)
3122  return std::numeric_limits<int64>::max();
3123 
3125  {
3126  int64 remaining = (int64(_GetRankBankMoneyPerDay(rankId)) * GOLD) - member->GetBankMoneyWithdrawValue();
3127  if (remaining > 0)
3128  return remaining;
3129  }
3130  }
3131  return 0;
3132 }
Definition: Guild.h:72
Definition: Guild.h:102
uint32 _GetRankRights(uint8 rankId) const
Definition: Guild.cpp:3070
int64_t int64
Definition: Define.h:147
uint32 _GetRankBankMoneyPerDay(uint8 rankId) const
Definition: Guild.cpp:3077
Definition: SharedDefines.h:250
Definition: Guild.h:103
uint8_t uint8
Definition: Define.h:154
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _GetMemberRemainingSlots()

int32 Guild::_GetMemberRemainingSlots ( Member const *  member,
uint8  tabId 
) const
inlineprivate
3100 {
3101  if (member)
3102  {
3103  uint8 rankId = member->GetRankId();
3104  if (rankId == GR_GUILDMASTER)
3105  return static_cast<int32>(GUILD_WITHDRAW_SLOT_UNLIMITED);
3106  if ((_GetRankBankTabRights(rankId, tabId) & GUILD_BANK_RIGHT_VIEW_TAB) != 0)
3107  {
3108  int32 remaining = _GetRankBankTabSlotsPerDay(rankId, tabId) - member->GetBankTabWithdrawValue(tabId);
3109  if (remaining > 0)
3110  return remaining;
3111  }
3112  }
3113  return 0;
3114 }
Definition: Guild.h:72
int32_t int32
Definition: Define.h:148
int32 _GetRankBankTabSlotsPerDay(uint8 rankId, uint8 tabId) const
Definition: Guild.cpp:3084
Definition: Guild.h:166
uint8_t uint8
Definition: Define.h:154
Definition: Guild.h:56
int8 _GetRankBankTabRights(uint8 rankId, uint8 tabId) const
Definition: Guild.cpp:3092
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _GetPurchasedTabsSize()

uint8 Guild::_GetPurchasedTabsSize ( ) const
inlineprivate
876 { return uint8(m_bankTabs.size()); }
BankTabs m_bankTabs
Definition: Guild.h:860
uint8_t uint8
Definition: Define.h:154
+ Here is the caller graph for this function:

◆ _GetRankBankMoneyPerDay()

uint32 Guild::_GetRankBankMoneyPerDay ( uint8  rankId) const
inlineprivate
3078 {
3079  if (RankInfo const* rankInfo = GetRankInfo(rankId))
3080  return rankInfo->GetBankMoneyPerDay();
3081  return 0;
3082 }
RankInfo const * GetRankInfo(uint8 rankId) const
Definition: Guild.h:870
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _GetRankBankTabRights()

int8 Guild::_GetRankBankTabRights ( uint8  rankId,
uint8  tabId 
) const
inlineprivate
3093 {
3094  if (RankInfo const* rankInfo = GetRankInfo(rankId))
3095  return rankInfo->GetBankTabRights(tabId);
3096  return 0;
3097 }
RankInfo const * GetRankInfo(uint8 rankId) const
Definition: Guild.h:870
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _GetRankBankTabSlotsPerDay()

int32 Guild::_GetRankBankTabSlotsPerDay ( uint8  rankId,
uint8  tabId 
) const
inlineprivate
3085 {
3086  if (tabId < _GetPurchasedTabsSize())
3087  if (RankInfo const* rankInfo = GetRankInfo(rankId))
3088  return rankInfo->GetBankTabSlotsPerDay(tabId);
3089  return 0;
3090 }
RankInfo const * GetRankInfo(uint8 rankId) const
Definition: Guild.h:870
uint8 _GetPurchasedTabsSize() const
Definition: Guild.h:876
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _GetRankName()

std::string Guild::_GetRankName ( uint8  rankId) const
inlineprivate
3064 {
3065  if (RankInfo const* rankInfo = GetRankInfo(rankId))
3066  return rankInfo->GetName();
3067  return "<unknown>";
3068 }
RankInfo const * GetRankInfo(uint8 rankId) const
Definition: Guild.h:870
+ Here is the call graph for this function:

◆ _GetRankRights()

uint32 Guild::_GetRankRights ( uint8  rankId) const
inlineprivate
3071 {
3072  if (RankInfo const* rankInfo = GetRankInfo(rankId))
3073  return rankInfo->GetRights();
3074  return 0;
3075 }
RankInfo const * GetRankInfo(uint8 rankId) const
Definition: Guild.h:870
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _GetRanksSize()

uint8 Guild::_GetRanksSize ( ) const
inlineprivate
869 { return uint8(m_ranks.size()); }
Ranks m_ranks
Definition: Guild.h:858
uint8_t uint8
Definition: Define.h:154
+ Here is the caller graph for this function:

◆ _HasRankRight()

bool Guild::_HasRankRight ( Player const *  player,
uint32  right 
) const
private
2884 {
2885  if (player)
2886  if (Member const* member = GetMember(player->GetGUID()))
2887  return (_GetRankRights(member->GetRankId()) & right) != GR_RIGHT_NONE;
2888  return false;
2889 }
uint32 _GetRankRights(uint8 rankId) const
Definition: Guild.cpp:3070
Definition: Guild.h:83
Member const * GetMember(ObjectGuid const &guid) const
Definition: Guild.h:880
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _IsLeader()

bool Guild::_IsLeader ( Player player) const
private
2989 {
2990  if (player->GetGUID() == m_leaderGuid)
2991  return true;
2992  if (Member const* member = GetMember(player->GetGUID()))
2993  return member->IsRank(GR_GUILDMASTER);
2994  return false;
2995 }
Definition: Guild.h:72
ObjectGuid m_leaderGuid
Definition: Guild.h:849
ObjectGuid const & GetGUID() const
Definition: Object.h:154
Member const * GetMember(ObjectGuid const &guid) const
Definition: Guild.h:880
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _LogBankEvent()

void Guild::_LogBankEvent ( CharacterDatabaseTransaction trans,
GuildBankEventLogTypes  eventType,
uint8  tabId,
ObjectGuid::LowType  playerGuid,
uint64  itemOrMoney,
uint16  itemStackCount = 0,
uint8  destTabId = 0 
)
private
3164 {
3165  if (tabId > GUILD_BANK_MAX_TABS)
3166  return;
3167 
3168  // not logging moves within the same tab
3169  if (eventType == GUILD_BANK_LOG_MOVE_ITEM && tabId == destTabId)
3170  return;
3171 
3172  uint8 dbTabId = tabId;
3173  if (BankEventLogEntry::IsMoneyEvent(eventType))
3174  {
3175  tabId = GUILD_BANK_MAX_TABS;
3176  dbTabId = GUILD_BANK_MONEY_LOGS_TAB;
3177  }
3178  LogHolder* pLog = m_bankEventLog[tabId];
3179  pLog->AddEvent(trans, new BankEventLogEntry(m_id, pLog->GetNextGUID(), eventType, dbTabId, lowguid, itemOrMoney, itemStackCount, destTabId));
3180 
3181  sScriptMgr->OnGuildBankEvent(this, uint8(eventType), tabId, lowguid, itemOrMoney, itemStackCount, destTabId);
3182 }
LogHolder * m_bankEventLog[GUILD_BANK_MAX_TABS+1]
Definition: Guild.h:864
Definition: Guild.h:50
Definition: Guild.h:178
Definition: Guild.h:48
void AddEvent(CharacterDatabaseTransaction &trans, LogEntry *entry)
Definition: Guild.cpp:96
bool IsMoneyEvent() const
Definition: Guild.h:454
ObjectGuid::LowType m_id
Definition: Guild.h:847
uint8_t uint8
Definition: Define.h:154
#define sScriptMgr
Definition: ScriptMgr.h:1235
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _LogEvent()

void Guild::_LogEvent ( GuildEventLogTypes  eventType,
ObjectGuid::LowType  playerGuid1,
ObjectGuid::LowType  playerGuid2 = UI64LIT(0),
uint8  newRank = 0 
)
inlineprivate
3154 {
3155  CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
3156  m_eventLog->AddEvent(trans, new EventLogEntry(m_id, m_eventLog->GetNextGUID(), eventType, playerGuid1, playerGuid2, newRank));
3157  CharacterDatabase.CommitTransaction(trans);
3158 
3159  sScriptMgr->OnGuildEvent(this, uint8(eventType), playerGuid1, playerGuid2, newRank);
3160 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
LogHolder * m_eventLog
Definition: Guild.h:863
void AddEvent(CharacterDatabaseTransaction &trans, LogEntry *entry)
Definition: Guild.cpp:96
uint32 GetNextGUID()
Definition: Guild.cpp:111
ObjectGuid::LowType m_id
Definition: Guild.h:847
uint8_t uint8
Definition: Define.h:154
#define sScriptMgr
Definition: ScriptMgr.h:1235
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:72
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _MemberHasTabRights()

bool Guild::_MemberHasTabRights ( ObjectGuid  guid,
uint8  tabId,
int32  rights 
) const
inlineprivate
3141 {
3142  if (Member const* member = GetMember(guid))
3143  {
3144  // Leader always has full rights
3145  if (member->IsRank(GR_GUILDMASTER) || m_leaderGuid == guid)
3146  return true;
3147  return (_GetRankBankTabRights(member->GetRankId(), tabId) & rights) == rights;
3148  }
3149  return false;
3150 }
Definition: Guild.h:72
ObjectGuid m_leaderGuid
Definition: Guild.h:849
Member const * GetMember(ObjectGuid const &guid) const
Definition: Guild.h:880
int8 _GetRankBankTabRights(uint8 rankId, uint8 tabId) const
Definition: Guild.cpp:3092
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _ModifyBankMoney()

bool Guild::_ModifyBankMoney ( CharacterDatabaseTransaction trans,
uint64  amount,
bool  add 
)
private
3009 {
3010  if (add)
3011  m_bankMoney += amount;
3012  else
3013  {
3014  // Check if there is enough money in bank.
3015  if (m_bankMoney < amount)
3016  return false;
3017  m_bankMoney -= amount;
3018  }
3019 
3021  stmt->setUInt64(0, m_bankMoney);
3022  stmt->setUInt64(1, m_id);
3023  trans->Append(stmt);
3024  return true;
3025 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: DatabaseEnvFwd.h:40
Definition: CharacterDatabase.h:243
ObjectGuid::LowType m_id
Definition: Guild.h:847
uint64 m_bankMoney
Definition: Guild.h:856
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _MoveItems()

void Guild::_MoveItems ( MoveItemData pSrc,
MoveItemData pDest,
uint32  splitedAmount 
) const
private
3198 {
3199  // 1. Initialize source item
3200  if (!pSrc->InitItem())
3201  return; // No source item
3202 
3203  // 2. Check source item
3204  if (!pSrc->CheckItem(splitedAmount))
3205  return; // Source item or splited amount is invalid
3206  /*
3207  if (pItemSrc->GetCount() == 0)
3208  {
3209  TC_LOG_FATAL("guild", "Guild::SwapItems: Player %s(GUIDLow: %u) tried to move item %u from tab %u slot %u to tab %u slot %u, but item %u has a stack of zero!",
3210  player->GetName(), player->GetGUIDLow(), pItemSrc->GetEntry(), tabId, slotId, destTabId, destSlotId, pItemSrc->GetEntry());
3211  //return; // Commented out for now, uncomment when it's verified that this causes a crash!!
3212  }
3213  // */
3214 
3215  // 3. Check destination rights
3216  if (!pDest->HasStoreRights(pSrc))
3217  return; // Player has no rights to store item in destination
3218 
3219  // 4. Check source withdraw rights
3220  if (!pSrc->HasWithdrawRights(pDest))
3221  return; // Player has no rights to withdraw items from source
3222 
3223  // 5. Check split
3224  if (splitedAmount)
3225  {
3226  // 5.1. Clone source item
3227  if (!pSrc->CloneItem(splitedAmount))
3228  return; // Item could not be cloned
3229 
3230  // 5.2. Move splited item to destination
3231  Guild::_DoItemsMove(pSrc, pDest, true, splitedAmount);
3232  }
3233  else // 6. No split
3234  {
3235  // 6.1. Try to merge items in destination (pDest->GetItem() == nullptr)
3236  InventoryResult mergeAttemptResult = Guild::_DoItemsMove(pSrc, pDest, false);
3237  if (mergeAttemptResult != EQUIP_ERR_OK) // Item could not be merged
3238  {
3239  // 6.2. Try to swap items
3240  // 6.2.1. Initialize destination item
3241  if (!pDest->InitItem())
3242  {
3243  pSrc->SendEquipError(mergeAttemptResult, pSrc->GetItem(false));
3244  return;
3245  }
3246 
3247  // 6.2.2. Check rights to store item in source (opposite direction)
3248  if (!pSrc->HasStoreRights(pDest))
3249  return; // Player has no rights to store item in source (opposite direction)
3250 
3251  if (!pDest->HasWithdrawRights(pSrc))
3252  return; // Player has no rights to withdraw item from destination (opposite direction)
3253 
3254  // 6.2.3. Swap items (pDest->GetItem() != nullptr)
3255  Guild::_DoItemsMove(pSrc, pDest, true);
3256  }
3257  }
3258  // 7. Send changes
3259  _SendBankContentUpdate(pSrc, pDest);
3260 }
static InventoryResult _DoItemsMove(MoveItemData *pSrc, MoveItemData *pDest, bool sendError, uint32 splitedAmount=0)
Definition: Guild.cpp:3262
InventoryResult
Definition: ItemDefines.h:23
Definition: ItemDefines.h:25
void _SendBankContentUpdate(MoveItemData *pSrc, MoveItemData *pDest) const
Definition: Guild.cpp:3310
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _RemoveItem()

void Guild::_RemoveItem ( CharacterDatabaseTransaction trans,
uint8  tabId,
uint8  slotId 
)
inlineprivate
3192 {
3193  if (BankTab* pTab = GetBankTab(tabId))
3194  pTab->SetItem(trans, slotId, nullptr);
3195 }
BankTab * GetBankTab(uint8 tabId)
Definition: Guild.h:877
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _SendBankContentUpdate() [1/2]

void Guild::_SendBankContentUpdate ( MoveItemData pSrc,
MoveItemData pDest 
) const
private
3311 {
3312  ASSERT(pSrc->IsBank() || pDest->IsBank());
3313 
3314  uint8 tabId = 0;
3315  SlotIds slots;
3316  if (pSrc->IsBank()) // B ->
3317  {
3318  tabId = pSrc->GetContainer();
3319  slots.insert(pSrc->GetSlotId());
3320  if (pDest->IsBank()) // B -> B
3321  {
3322  // Same tab - add destination slots to collection
3323  if (pDest->GetContainer() == pSrc->GetContainer())
3324  pDest->CopySlots(slots);
3325  else // Different tabs - send second message
3326  {
3327  SlotIds destSlots;
3328  pDest->CopySlots(destSlots);
3329  _SendBankContentUpdate(pDest->GetContainer(), destSlots);
3330  }
3331  }
3332  }
3333  else if (pDest->IsBank()) // C -> B
3334  {
3335  tabId = pDest->GetContainer();
3336  pDest->CopySlots(slots);
3337  }
3338 
3339  _SendBankContentUpdate(tabId, slots);
3340 }
std::set< uint8 > SlotIds
Definition: Guild.h:303
uint8_t uint8
Definition: Define.h:154
void _SendBankContentUpdate(MoveItemData *pSrc, MoveItemData *pDest) const
Definition: Guild.cpp:3310
#define ASSERT
Definition: Errors.h:61
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _SendBankContentUpdate() [2/2]

void Guild::_SendBankContentUpdate ( uint8  tabId,
SlotIds  slots 
) const
private
3343 {
3344  if (BankTab const* tab = GetBankTab(tabId))
3345  {
3347  packet.FullUpdate = true; // @todo
3348  packet.Tab = int32(tabId);
3349  packet.Money = m_bankMoney;
3350 
3351  for (SlotIds::const_iterator itr = slots.begin(); itr != slots.end(); ++itr)
3352  {
3353  Item const* tabItem = tab->GetItem(*itr);
3354 
3356 
3357  itemInfo.Slot = int32(*itr);
3358  itemInfo.Item.ItemID = int32(tabItem ? tabItem->GetEntry() : 0);
3359  itemInfo.Count = int32(tabItem ? tabItem->GetCount() : 0);
3360  itemInfo.EnchantmentID = int32(tabItem ? tabItem->GetEnchantmentId(PERM_ENCHANTMENT_SLOT) : 0);
3361  itemInfo.Charges = int32(tabItem ? abs(tabItem->GetSpellCharges()) : 0);
3362  itemInfo.OnUseEnchantmentID = int32(tabItem ? tabItem->GetEnchantmentId(USE_ENCHANTMENT_SLOT) : 0);
3363  itemInfo.Flags = 0;
3364  itemInfo.Locked = false;
3365 
3366  if (tabItem)
3367  {
3368  uint8 i = 0;
3369  for (UF::SocketedGem const& gemData : tabItem->m_itemData->Gems)
3370  {
3371  if (gemData.ItemID)
3372  {
3374  gem.Slot = i;
3375  gem.Item.Initialize(&gemData);
3376  itemInfo.SocketEnchant.push_back(gem);
3377  }
3378  ++i;
3379  }
3380  }
3381 
3382  packet.ItemInfo.push_back(itemInfo);
3383  }
3384 
3385  for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
3386  if (_MemberHasTabRights(itr->second->GetGUID(), tabId, GUILD_BANK_RIGHT_VIEW_TAB))
3387  if (Player* player = itr->second->FindPlayer())
3388  {
3389  packet.WithdrawalsRemaining = _GetMemberRemainingSlots(itr->second, tabId);
3390  player->GetSession()->SendPacket(packet.Write());
3391  }
3392  }
3393 }
WorldPackets::Item::ItemInstance Item
Definition: GuildPackets.h:800
ItemInstance Item
Definition: ItemPacketsCommon.h:97
int32 Charges
Definition: GuildPackets.h:804
Definition: GuildPackets.h:818
int32 OnUseEnchantmentID
Definition: GuildPackets.h:805
uint8 Slot
Definition: ItemPacketsCommon.h:96
int32 Count
Definition: GuildPackets.h:802
Definition: ItemPacketsCommon.h:94
BankTab * GetBankTab(uint8 tabId)
Definition: Guild.h:877
int32 Flags
Definition: GuildPackets.h:806
int32 Slot
Definition: GuildPackets.h:801
bool Locked
Definition: GuildPackets.h:807
std::vector< Item::ItemGemData > SocketEnchant
Definition: GuildPackets.h:808
UpdateField< int32, 0, 1 > ItemID
Definition: UpdateFields.h:106
Definition: UpdateFields.h:104
int32 GetSpellCharges(uint8 index=0) const
Definition: Item.h:305
int32 Tab
Definition: GuildPackets.h:828
Definition: GuildPackets.h:798
Definition: Item.h:169
Members m_members
Definition: Guild.h:859
int32_t int32
Definition: Define.h:148
int32 EnchantmentID
Definition: GuildPackets.h:803
uint64 Money
Definition: GuildPackets.h:829
uint32 GetCount() const
Definition: Item.h:264
Definition: ItemDefines.h:165
int32 _GetMemberRemainingSlots(Member const *member, uint8 tabId) const
Definition: Guild.cpp:3099
uint32 GetEntry() const
Definition: Object.h:155
uint32 GetEnchantmentId(EnchantmentSlot slot) const
Definition: Item.h:289
std::vector< GuildBankItemInfo > ItemInfo
Definition: GuildPackets.h:825
UF::UpdateField< UF::ItemData, 0, TYPEID_ITEM > m_itemData
Definition: Item.h:424
void Initialize(::Item const *item)
Definition: ItemPacketsCommon.cpp:50
Definition: Guild.h:166
uint8_t uint8
Definition: Define.h:154
Definition: ItemDefines.h:172
uint64 m_bankMoney
Definition: Guild.h:856
WorldPacket const * Write() override
Definition: GuildPackets.cpp:611
Definition: Player.h:1081
bool _MemberHasTabRights(ObjectGuid guid, uint8 tabId, int32 rights) const
Definition: Guild.cpp:3140
uint32 ItemID
Definition: ItemPacketsCommon.h:77
bool FullUpdate
Definition: GuildPackets.h:830
int32 WithdrawalsRemaining
Definition: GuildPackets.h:827
+ Here is the call graph for this function:

◆ _SetLeader()

void Guild::_SetLeader ( CharacterDatabaseTransaction trans,
Member leader 
)
private
3028 {
3029  if (!leader)
3030  return;
3031 
3032  bool isInTransaction = bool(trans);
3033  if (!isInTransaction)
3034  trans = CharacterDatabase.BeginTransaction();
3035 
3036  m_leaderGuid = leader->GetGUID();
3037  leader->ChangeRank(trans, GR_GUILDMASTER);
3038 
3040  stmt->setUInt64(0, m_leaderGuid.GetCounter());
3041  stmt->setUInt64(1, m_id);
3042  trans->Append(stmt);
3043 
3044  if (!isInTransaction)
3045  CharacterDatabase.CommitTransaction(trans);
3046 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: Guild.h:72
LowType GetCounter() const
Definition: ObjectGuid.h:273
Definition: CharacterDatabase.h:238
Definition: DatabaseEnvFwd.h:40
ObjectGuid m_leaderGuid
Definition: Guild.h:849
ObjectGuid::LowType m_id
Definition: Guild.h:847
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _SetRankBankMoneyPerDay()

void Guild::_SetRankBankMoneyPerDay ( uint8  rankId,
uint32  moneyPerDay 
)
private
3049 {
3050  if (RankInfo* rankInfo = GetRankInfo(rankId))
3051  rankInfo->SetBankMoneyPerDay(moneyPerDay);
3052 }
RankInfo const * GetRankInfo(uint8 rankId) const
Definition: Guild.h:870
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _SetRankBankTabRightsAndSlots()

void Guild::_SetRankBankTabRightsAndSlots ( uint8  rankId,
GuildBankRightsAndSlots  rightsAndSlots,
bool  saveToDB = true 
)
private
3055 {
3056  if (rightsAndSlots.GetTabId() >= _GetPurchasedTabsSize())
3057  return;
3058 
3059  if (RankInfo* rankInfo = GetRankInfo(rankId))
3060  rankInfo->SetBankTabSlotsAndRights(rightsAndSlots, saveToDB);
3061 }
RankInfo const * GetRankInfo(uint8 rankId) const
Definition: Guild.h:870
int8 GetTabId() const
Definition: Guild.h:291
uint8 _GetPurchasedTabsSize() const
Definition: Guild.h:876
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _UpdateAccountsNumber()

void Guild::_UpdateAccountsNumber ( )
private
2976 {
2977  // We use a set to be sure each element will be unique
2978  std::set<uint32> accountsIdSet;
2979  for (auto itr = m_members.begin(); itr != m_members.end(); ++itr)
2980  accountsIdSet.insert(itr->second->GetAccountId());
2981 
2982  m_accountsNumber = accountsIdSet.size();
2983 }
uint32 m_accountsNumber
Definition: Guild.h:855
Members m_members
Definition: Guild.h:859
+ Here is the caller graph for this function:

◆ _UpdateMemberWithdrawSlots()

void Guild::_UpdateMemberWithdrawSlots ( CharacterDatabaseTransaction trans,
ObjectGuid  guid,
uint8  tabId 
)
inlineprivate
3135 {
3136  if (Member* member = GetMember(guid))
3137  member->UpdateBankTabWithdrawValue(trans, tabId, 1);
3138 }
Member const * GetMember(ObjectGuid const &guid) const
Definition: Guild.h:880
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddGuildNews()

void Guild::AddGuildNews ( uint8  type,
ObjectGuid  guid,
uint32  flags,
uint32  value 
) const
3507 {
3508  NewsLogEntry* news = new NewsLogEntry(m_id, m_newsLog->GetNextGUID(), GuildNews(type), guid, flags, value);
3509 
3510  CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
3511  m_newsLog->AddEvent(trans, news);
3512  CharacterDatabase.CommitTransaction(trans);
3513 
3514  WorldPackets::Guild::GuildNews newsPacket;
3515  newsPacket.NewsEvents.reserve(1);
3516  news->WritePacket(newsPacket);
3517  BroadcastPacket(newsPacket.Write());
3518 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: GuildPackets.h:1090
WorldPacket const * Write() override
Definition: GuildPackets.cpp:895
void BroadcastPacket(WorldPacket const *packet) const
Definition: Guild.cpp:2636
void AddEvent(CharacterDatabaseTransaction &trans, LogEntry *entry)
Definition: Guild.cpp:96
GuildNews
Definition: Guild.h:217
uint32 GetNextGUID()
Definition: Guild.cpp:111
ObjectGuid::LowType m_id
Definition: Guild.h:847
uint8 flags
Definition: DisableMgr.cpp:47
std::vector< GuildNewsEvent > NewsEvents
Definition: GuildPackets.h:1097
LogHolder * m_newsLog
Definition: Guild.h:865
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:72
+ Here is the call graph for this function:

◆ AddMember()

bool Guild::AddMember ( CharacterDatabaseTransaction trans,
ObjectGuid  guid,
uint8  rankId = GUILD_RANK_NONE 
)
2677 {
2679  // Player cannot be in guild
2680  if (player)
2681  {
2682  if (player->GetGuildId())
2683  return false;
2684  }
2685  else if (sCharacterCache->GetCharacterGuildIdByGuid(guid))
2686  return false;
2687 
2688  // Remove all player signs from another petitions
2689  // This will be prevent attempt to join many guilds and corrupt guild data integrity
2691 
2692  ObjectGuid::LowType lowguid = guid.GetCounter();
2693 
2694  // If rank was not passed, assign lowest possible rank
2695  if (rankId == GUILD_RANK_NONE)
2696  rankId = _GetLowestRankId();
2697 
2698  Member* member = new Member(m_id, guid, rankId);
2699  std::string name;
2700  if (player)
2701  {
2702  m_members[guid] = member;
2703  player->SetInGuild(m_id);
2704  player->SetGuildIdInvited(UI64LIT(0));
2705  player->SetGuildRank(rankId);
2706  player->SetGuildLevel(GetLevel());
2707  SendLoginInfo(player->GetSession());
2708  name = player->GetName();
2709  }
2710  else
2711  {
2712  member->ResetFlags();
2713 
2714  bool ok = false;
2715  // Player must exist
2717  stmt->setUInt64(0, lowguid);
2718  if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
2719  {
2720  Field* fields = result->Fetch();
2721  name = fields[0].GetString();
2722  member->SetStats(
2723  name,
2724  fields[1].GetUInt8(),
2725  fields[2].GetUInt8(),
2726  fields[3].GetUInt8(),
2727  fields[4].GetUInt16(),
2728  fields[5].GetUInt32(),
2729  0);
2730 
2731  ok = member->CheckStats();
2732  }
2733 
2734  if (!ok)
2735  {
2736  delete member;
2737  return false;
2738  }
2739  m_members[guid] = member;
2740  sCharacterCache->UpdateCharacterGuildId(guid, GetId());
2741  }
2742 
2743  member->SaveToDB(trans);
2744 
2747 
2748  WorldPackets::Guild::GuildEventPlayerJoined joinNotificationPacket;
2749  joinNotificationPacket.Guid = guid;
2750  joinNotificationPacket.Name = name;
2751  joinNotificationPacket.VirtualRealmAddress = GetVirtualRealmAddress();
2752  BroadcastPacket(joinNotificationPacket.Write());
2753 
2754  sGuildFinderMgr->RemoveAllMembershipRequestsFromPlayer(guid);
2755 
2756  // Call scripts if member was succesfully added (and stored to database)
2757  sScriptMgr->OnGuildAddMember(this, player, rankId);
2758 
2759  return true;
2760 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
uint32 VirtualRealmAddress
Definition: GuildPackets.h:279
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: DatabaseEnvFwd.h:48
WorldSession * GetSession() const
Definition: Player.h:2018
Class used to access individual fields of database query result.
Definition: Field.h:81
uint64 LowType
Definition: ObjectGuid.h:258
LowType GetCounter() const
Definition: ObjectGuid.h:273
#define UI64LIT(N)
Definition: Define.h:140
Definition: Guild.h:191
std::string Name
Definition: GuildPackets.h:278
Definition: DatabaseEnvFwd.h:40
void BroadcastPacket(WorldPacket const *packet) const
Definition: Guild.cpp:2636
void SetInGuild(ObjectGuid::LowType guildId)
Definition: Player.cpp:7106
void SetGuildRank(uint8 rankId)
Definition: Player.h:1908
#define sCharacterCache
Definition: CharacterCache.h:73
std::string const & GetName() const
Definition: Object.h:467
ObjectGuid::LowType GetId() const
Definition: Guild.h:725
WorldPacket const * Write() override
Definition: GuildPackets.cpp:234
std::string GetString() const
Definition: Field.cpp:228
Members m_members
Definition: Guild.h:859
Definition: Guild.h:54
Definition: CharacterDatabase.h:249
static void RemovePetitionsAndSigns(ObjectGuid guid)
Definition: Player.cpp:22635
void _LogEvent(GuildEventLogTypes eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2=UI64LIT(0), uint8 newRank=0)
Definition: Guild.cpp:3153
Definition: GuildPackets.h:270
ObjectGuid::LowType m_id
Definition: Guild.h:847
uint8 GetLevel() const
Definition: Guild.h:836
void _UpdateAccountsNumber()
Definition: Guild.cpp:2975
ObjectGuid::LowType GetGuildId() const
Definition: Player.h:1913
uint32 GetVirtualRealmAddress()
Definition: World.cpp:3737
void SetGuildIdInvited(ObjectGuid::LowType GuildId)
Definition: Player.h:1912
#define sScriptMgr
Definition: ScriptMgr.h:1235
void SetGuildLevel(uint32 level)
Definition: Player.h:1910
#define sGuildFinderMgr
Definition: GuildFinderMgr.h:250
uint8 _GetLowestRankId() const
Definition: Guild.h:874
ObjectGuid Guid
Definition: GuildPackets.h:277
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
Definition: Player.h:1081
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:285
void SendLoginInfo(WorldSession *session)
Definition: Guild.cpp:2221
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BroadcastAddonToGuild()

void Guild::BroadcastAddonToGuild ( WorldSession session,
bool  officerOnly,
std::string const &  msg,
std::string const &  prefix,
bool  isLogged 
) const
2613 {
2614  if (session && session->GetPlayer() && _HasRankRight(session->GetPlayer(), officerOnly ? GR_RIGHT_OFFCHATSPEAK : GR_RIGHT_GCHATSPEAK))
2615  {
2616  WorldPackets::Chat::Chat packet;
2617  packet.Initialize(officerOnly ? CHAT_MSG_OFFICER : CHAT_MSG_GUILD, isLogged ? LANG_ADDON_LOGGED : LANG_ADDON, session->GetPlayer(), nullptr, msg, 0, "", DEFAULT_LOCALE, prefix);
2618  WorldPacket const* data = packet.Write();
2619  for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
2620  if (Player* player = itr->second->FindPlayer())
2621  if (player->GetSession() && _HasRankRight(player, officerOnly ? GR_RIGHT_OFFCHATLISTEN : GR_RIGHT_GCHATLISTEN) &&
2622  !player->GetSocial()->HasIgnore(session->GetPlayer()->GetGUID()) &&
2623  player->GetSession()->IsAddonRegistered(prefix))
2624  player->SendDirectMessage(data);
2625  }
2626 }
Definition: Guild.h:87
constexpr auto data(C &c)
Definition: advstd.h:96
Definition: Guild.h:86
Definition: SharedDefines.h:5554
Definition: ChatPackets.h:146
Definition: SharedDefines.h:5555
bool _HasRankRight(Player const *player, uint32 right) const
Definition: Guild.cpp:2883
Definition: SharedDefines.h:1073
ObjectGuid const & GetGUID() const
Definition: Object.h:154
void Initialize(ChatMsg chatType, Language language, WorldObject const *sender, WorldObject const *receiver, std::string message, uint32 achievementId=0, std::string channelName="", LocaleConstant locale=DEFAULT_LOCALE, std::string addonPrefix="")
Definition: ChatPackets.cpp:105
Members m_members
Definition: Guild.h:859
Definition: Guild.h:84
WorldPacket const * Write() override
Definition: ChatPackets.cpp:163
Player * GetPlayer() const
Definition: WorldSession.h:984
#define DEFAULT_LOCALE
Definition: Common.h:99
Definition: Guild.h:85
Definition: Player.h:1081
Definition: WorldPacket.h:24
Definition: SharedDefines.h:1072
+ Here is the call graph for this function:

◆ BroadcastPacket()

void Guild::BroadcastPacket ( WorldPacket const *  packet) const
2637 {
2638  for (auto itr = m_members.begin(); itr != m_members.end(); ++itr)
2639  if (Player* player = itr->second->FindPlayer())
2640  player->SendDirectMessage(packet);
2641 }
Members m_members
Definition: Guild.h:859
Definition: Player.h:1081
+ Here is the caller graph for this function:

◆ BroadcastPacketIfTrackingAchievement()

void Guild::BroadcastPacketIfTrackingAchievement ( WorldPacket const *  packet,
uint32  criteriaId 
) const
2644 {
2645  for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
2646  if (itr->second->IsTrackingCriteriaId(criteriaId))
2647  if (Player* player = itr->second->FindPlayer())
2648  player->GetSession()->SendPacket(packet);
2649 }
Members m_members
Definition: Guild.h:859
Definition: Player.h:1081
+ Here is the caller graph for this function:

◆ BroadcastPacketToRank()

void Guild::BroadcastPacketToRank ( WorldPacket const *  packet,
uint8  rankId 
) const
2629 {
2630  for (auto itr = m_members.begin(); itr != m_members.end(); ++itr)
2631  if (itr->second->IsRank(rankId))
2632  if (Player* player = itr->second->FindConnectedPlayer())
2633  player->SendDirectMessage(packet);
2634 }
Members m_members
Definition: Guild.h:859
Definition: Player.h:1081
+ Here is the caller graph for this function:

◆ BroadcastToGuild()

void Guild::BroadcastToGuild ( WorldSession session,
bool  officerOnly,
std::string const &  msg,
uint32  language = LANG_UNIVERSAL 
) const
2598 {
2599  if (session && session->GetPlayer() && _HasRankRight(session->GetPlayer(), officerOnly ? GR_RIGHT_OFFCHATSPEAK : GR_RIGHT_GCHATSPEAK))
2600  {
2601  WorldPackets::Chat::Chat packet;
2602  packet.Initialize(officerOnly ? CHAT_MSG_OFFICER : CHAT_MSG_GUILD, Language(language), session->GetPlayer(), nullptr, msg);
2603  WorldPacket const* data = packet.Write();
2604  for (auto itr = m_members.begin(); itr != m_members.end(); ++itr)
2605  if (Player* player = itr->second->FindConnectedPlayer())
2606  if (player->GetSession() && _HasRankRight(player, officerOnly ? GR_RIGHT_OFFCHATLISTEN : GR_RIGHT_GCHATLISTEN) &&
2607  !player->GetSocial()->HasIgnore(session->GetPlayer()->GetGUID()))
2608  player->SendDirectMessage(data);
2609  }
2610 }
Definition: Guild.h:87
constexpr auto data(C &c)
Definition: advstd.h:96
Definition: Guild.h:86
Definition: SharedDefines.h:5554
Definition: ChatPackets.h:146
Definition: SharedDefines.h:5555
bool _HasRankRight(Player const *player, uint32 right) const
Definition: Guild.cpp:2883
ObjectGuid const & GetGUID() const
Definition: Object.h:154
Language
Definition: SharedDefines.h:1041
void Initialize(ChatMsg chatType, Language language, WorldObject const *sender, WorldObject const *receiver, std::string message, uint32 achievementId=0, std::string channelName="", LocaleConstant locale=DEFAULT_LOCALE, std::string addonPrefix="")
Definition: ChatPackets.cpp:105
Members m_members
Definition: Guild.h:859
Definition: Guild.h:84
WorldPacket const * Write() override
Definition: ChatPackets.cpp:163
Player * GetPlayer() const
Definition: WorldSession.h:984
Definition: Guild.h:85
Definition: Player.h:1081
Definition: WorldPacket.h:24
+ Here is the call graph for this function:

◆ BroadcastWorker()

template<class Do >
void Guild::BroadcastWorker ( Do &  _do,
Player except = nullptr 
)
inline
810  {
811  for (auto itr = m_members.begin(); itr != m_members.end(); ++itr)
812  if (Player* player = itr->second->FindConnectedPlayer())
813  if (player != except)
814  _do(player);
815  }
Members m_members
Definition: Guild.h:859
Definition: Player.h:1081

◆ ChangeMemberRank()

bool Guild::ChangeMemberRank ( CharacterDatabaseTransaction trans,
ObjectGuid  guid,
uint8  newRank 
)
2822 {
2823  if (newRank <= _GetLowestRankId()) // Validate rank (allow only existing ranks)
2824  {
2825  if (Member* member = GetMember(guid))
2826  {
2827  member->ChangeRank(trans, newRank);
2828  return true;
2829  }
2830  }
2831 
2832  return false;
2833 }
Member const * GetMember(ObjectGuid const &guid) const
Definition: Guild.h:880
uint8 _GetLowestRankId() const
Definition: Guild.h:874
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Create()

bool Guild::Create ( Player pLeader,
std::string const &  name 
)
1147 {
1148  // Check if guild with such name already exists
1149  if (sGuildMgr->GetGuildByName(name))
1150  return false;
1151 
1152  WorldSession* pLeaderSession = pLeader->GetSession();
1153  if (!pLeaderSession)
1154  return false;
1155 
1156  m_id = sGuildMgr->GenerateGuildId();
1157  m_leaderGuid = pLeader->GetGUID();
1158  m_name = name;
1159  m_info = "";
1160  m_motd = "No message set.";
1161  m_bankMoney = 0;
1164 
1165  TC_LOG_DEBUG("guild", "GUILD: creating guild [%s] for leader %s (%s)",
1166  name.c_str(), pLeader->GetName().c_str(), m_leaderGuid.ToString().c_str());
1167 
1168  CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
1169 
1171  stmt->setUInt64(0, m_id);
1172  trans->Append(stmt);
1173 
1174  uint8 index = 0;
1175  stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD);
1176  stmt->setUInt64( index, m_id);
1177  stmt->setString(++index, name);
1178  stmt->setUInt64(++index, m_leaderGuid.GetCounter());
1179  stmt->setString(++index, m_info);
1180  stmt->setString(++index, m_motd);
1181  stmt->setUInt64(++index, uint32(m_createdDate));
1182  stmt->setUInt32(++index, m_emblemInfo.GetStyle());
1183  stmt->setUInt32(++index, m_emblemInfo.GetColor());
1184  stmt->setUInt32(++index, m_emblemInfo.GetBorderStyle());
1185  stmt->setUInt32(++index, m_emblemInfo.GetBorderColor());
1186  stmt->setUInt32(++index, m_emblemInfo.GetBackgroundColor());
1187  stmt->setUInt64(++index, m_bankMoney);
1188  trans->Append(stmt);
1189 
1190  _CreateDefaultGuildRanks(trans, pLeaderSession->GetSessionDbLocaleIndex()); // Create default ranks
1191  bool ret = AddMember(trans, m_leaderGuid, GR_GUILDMASTER); // Add guildmaster
1192 
1193  CharacterDatabase.CommitTransaction(trans);
1194 
1195  if (ret)
1196  {
1197  Member* leader = GetMember(m_leaderGuid);
1198  if (leader)
1199  SendEventNewLeader(leader, nullptr);
1200 
1201  sScriptMgr->OnGuildCreate(this, pLeader, name);
1202  }
1203 
1204  return ret;
1205 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: Guild.h:72
Definition: CharacterDatabase.h:213
LocaleConstant GetSessionDbLocaleIndex() const
Definition: WorldSession.h:1120
uint32 GetStyle() const
Definition: Guild.h:259
uint32 GetColor() const
Definition: Guild.h:260
std::string ToString() const
Definition: ObjectGuid.cpp:238
EmblemInfo m_emblemInfo
Definition: Guild.h:854
#define sGuildMgr
Definition: GuildMgr.h:69
void _CreateDefaultGuildRanks(CharacterDatabaseTransaction &trans, LocaleConstant loc)
Definition: Guild.cpp:2931
WorldSession * GetSession() const
Definition: Player.h:2018
uint32 GetBorderStyle() const
Definition: Guild.h:261
LowType GetCounter() const
Definition: ObjectGuid.h:273
time_t m_createdDate
Definition: Guild.h:852
Definition: CharacterDatabase.h:208
Definition: DatabaseEnvFwd.h:40
ObjectGuid m_leaderGuid
Definition: Guild.h:849
void SendEventNewLeader(Member *newLeader, Member *oldLeader, bool isSelfPromoted=false) const
Definition: Guild.cpp:2308
bool AddMember(CharacterDatabaseTransaction &trans, ObjectGuid guid, uint8 rankId=GUILD_RANK_NONE)
Definition: Guild.cpp:2676
ObjectGuid const & GetGUID() const
Definition: Object.h:154
std::string const & GetName() const
Definition: Object.h:467
std::string m_motd
Definition: Guild.h:850
time_t GetGameTime()
Definition: GameTime.cpp:39
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:116
uint32_t uint32
Definition: Define.h:152
std::string m_name
Definition: Guild.h:848
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:180
uint32 GetBorderColor() const
Definition: Guild.h:262
void _CreateLogHolders()
Definition: Guild.cpp:2899
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
ObjectGuid::LowType m_id
Definition: Guild.h:847
uint8_t uint8
Definition: Define.h:154
#define sScriptMgr
Definition: ScriptMgr.h:1235
Member const * GetMember(ObjectGuid const &guid) const
Definition: Guild.h:880
uint64 m_bankMoney
Definition: Guild.h:856
uint32 GetBackgroundColor() const
Definition: Guild.h:263
Player session in the World.
Definition: WorldSession.h:941
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
std::string m_info
Definition: Guild.h:851
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:72
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DeleteMember()

void Guild::DeleteMember ( CharacterDatabaseTransaction trans,
ObjectGuid  guid,
bool  isDisbanding = false,
bool  isKicked = false,
bool  canDeleteGuild = false 
)
2763 {
2764  // Guild master can be deleted when loading guild and guid doesn't exist in characters table
2765  // or when he is removed from guild by gm command
2766  if (m_leaderGuid == guid && !isDisbanding)
2767  {
2768  Member* oldLeader = nullptr;
2769  Member* newLeader = nullptr;
2770  for (auto i = m_members.begin(); i != m_members.end(); ++i)
2771  {
2772  if (i->first == guid)
2773  oldLeader = i->second;
2774  else if (!newLeader || newLeader->GetRankId() > i->second->GetRankId())
2775  newLeader = i->second;
2776  }
2777 
2778  if (!newLeader)
2779  {
2780  Disband();
2781  if (canDeleteGuild)
2782  delete this;
2783  return;
2784  }
2785 
2786  _SetLeader(trans, newLeader);
2787 
2788  // If leader does not exist (at guild loading with deleted leader) do not send broadcasts
2789  if (oldLeader)
2790  {
2791  SendEventNewLeader(newLeader, oldLeader, true);
2792  SendEventPlayerLeft(oldLeader);
2793  }
2794  }
2795  // Call script on remove before member is actually removed from guild (and database)
2796  sScriptMgr->OnGuildRemoveMember(this, guid, isDisbanding, isKicked);
2797 
2798  if (Member* member = GetMember(guid))
2799  delete member;
2800  m_members.erase(guid);
2801 
2802  // If player not online data in data field will be loaded from guild tabs no need to update it !!
2804  if (player)
2805  {
2806  player->SetInGuild(UI64LIT(0));
2807  player->SetGuildRank(0);
2808  player->SetGuildLevel(0);
2809 
2810  for (GuildPerkSpellsEntry const* entry : sGuildPerkSpellsStore)
2811  player->RemoveSpell(entry->SpellID, false, false);
2812  }
2813  else
2814  sCharacterCache->UpdateCharacterGuildId(guid, 0);
2815 
2816  Guild::_DeleteMemberFromDB(trans, guid.GetCounter());
2817  if (!isDisbanding)
2819 }
void RemoveSpell(uint32 spell_id, bool disabled=false, bool learn_low_rank=true, bool suppressMessaging=false)
Definition: Player.cpp:3217
LowType GetCounter() const
Definition: ObjectGuid.h:273
#define UI64LIT(N)
Definition: Define.h:140
void SendEventPlayerLeft(Member *leaver, Member *remover=nullptr, bool isRemoved=false) const
Definition: Guild.cpp:2329
DB2Storage< GuildPerkSpellsEntry > sGuildPerkSpellsStore("GuildPerkSpells.db2", GuildPerkSpellsLoadInfo::Instance())
void Disband()
Definition: Guild.cpp:1208
ObjectGuid m_leaderGuid
Definition: Guild.h:849
void SetInGuild(ObjectGuid::LowType guildId)
Definition: Player.cpp:7106
void SendEventNewLeader(Member *newLeader, Member *oldLeader, bool isSelfPromoted=false) const
Definition: Guild.cpp:2308
void SetGuildRank(uint8 rankId)
Definition: Player.h:1908
#define sCharacterCache
Definition: CharacterCache.h:73
Definition: DB2Structure.h:1752
Members m_members
Definition: Guild.h:859
void _UpdateAccountsNumber()
Definition: Guild.cpp:2975
void _SetLeader(CharacterDatabaseTransaction &trans, Member *leader)
Definition: Guild.cpp:3027
#define sScriptMgr
Definition: ScriptMgr.h:1235
Member const * GetMember(ObjectGuid const &guid) const
Definition: Guild.h:880
static void _DeleteMemberFromDB(CharacterDatabaseTransaction &trans, ObjectGuid::LowType lowguid)
Definition: Guild.cpp:2891
void SetGuildLevel(uint32 level)
Definition: Player.h:1910
Definition: Player.h:1081
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:285
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Disband()

void Guild::Disband ( )
1209 {
1210  // Call scripts before guild data removed from database
1211  sScriptMgr->OnGuildDisband(this);
1212 
1214  BroadcastPacket(packet.Write());
1215 
1216  CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
1217  // Remove all members
1218  while (!m_members.empty())
1219  {
1220  auto itr = m_members.begin();
1221  DeleteMember(trans, itr->second->GetGUID(), true);
1222  }
1223 
1225  stmt->setUInt64(0, m_id);
1226  trans->Append(stmt);
1227 
1228  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_RANKS);
1229  stmt->setUInt64(0, m_id);
1230  trans->Append(stmt);
1231 
1232  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_TABS);
1233  stmt->setUInt64(0, m_id);
1234  trans->Append(stmt);
1235 
1236  // Free bank tab used memory and delete items stored in them
1237  _DeleteBankItems(trans, true);
1238 
1239  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_ITEMS);
1240  stmt->setUInt64(0, m_id);
1241  trans->Append(stmt);
1242 
1243  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_RIGHTS);
1244  stmt->setUInt64(0, m_id);
1245  trans->Append(stmt);
1246 
1247  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_EVENTLOGS);
1248  stmt->setUInt64(0, m_id);
1249  trans->Append(stmt);
1250 
1251  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_EVENTLOGS);
1252  stmt->setUInt64(0, m_id);
1253  trans->Append(stmt);
1254 
1255  CharacterDatabase.CommitTransaction(trans);
1256 
1257  sGuildFinderMgr->DeleteGuild(GetGUID());
1258 
1259  sGuildMgr->RemoveGuild(m_id);
1260 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: CharacterDatabase.h:209
void DeleteMember(CharacterDatabaseTransaction &trans, ObjectGuid guid, bool isDisbanding=false, bool isKicked=false, bool canDeleteGuild=false)
Definition: Guild.cpp:2762
#define sGuildMgr
Definition: GuildMgr.h:69
void _DeleteBankItems(CharacterDatabaseTransaction &trans, bool removeItemsFromDB=false)
Definition: Guild.cpp:2997
Definition: CharacterDatabase.h:219
Definition: DatabaseEnvFwd.h:40
Definition: CharacterDatabase.h:215
void BroadcastPacket(WorldPacket const *packet) const
Definition: Guild.cpp:2636
Definition: CharacterDatabase.h:229
Definition: CharacterDatabase.h:225
WorldPacket const * Write() override
Definition: GuildPackets.h:315
Members m_members
Definition: Guild.h:859
Definition: GuildPackets.h:310
ObjectGuid::LowType m_id
Definition: Guild.h:847
ObjectGuid GetGUID() const
Definition: Guild.h:726
#define sScriptMgr
Definition: ScriptMgr.h:1235
#define sGuildFinderMgr
Definition: GuildFinderMgr.h:250
Definition: CharacterDatabase.h:232
Definition: CharacterDatabase.h:223
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:72
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetAchievementMgr() [1/2]

GuildAchievementMgr& Guild::GetAchievementMgr ( )
inline
832 { return m_achievementMgr; }
GuildAchievementMgr m_achievementMgr
Definition: Guild.h:866
+ Here is the caller graph for this function:

◆ GetAchievementMgr() [2/2]

GuildAchievementMgr const& Guild::GetAchievementMgr ( ) const
inline
833 { return m_achievementMgr; }
GuildAchievementMgr m_achievementMgr
Definition: Guild.h:866

◆ GetBankMoney()

uint64 Guild::GetBankMoney ( ) const
inline
732 { return m_bankMoney; }
uint64 m_bankMoney
Definition: Guild.h:856
+ Here is the caller graph for this function:

◆ GetBankTab() [1/2]

BankTab* Guild::GetBankTab ( uint8  tabId)
inlineprivate
877 { return tabId < m_bankTabs.size() ? m_bankTabs[tabId] : nullptr; }
BankTabs m_bankTabs
Definition: Guild.h:860
+ Here is the caller graph for this function:

◆ GetBankTab() [2/2]

BankTab const* Guild::GetBankTab ( uint8  tabId) const
inlineprivate
878 { return tabId < m_bankTabs.size() ? m_bankTabs[tabId] : nullptr; }
BankTabs m_bankTabs
Definition: Guild.h:860

◆ GetCreatedDate()

time_t Guild::GetCreatedDate ( ) const
inline
731 { return m_createdDate; }
time_t m_createdDate
Definition: Guild.h:852
+ Here is the caller graph for this function:

◆ GetEmblemInfo()

EmblemInfo const& Guild::GetEmblemInfo ( ) const
inline
840 { return m_emblemInfo; }
EmblemInfo m_emblemInfo
Definition: Guild.h:854
+ Here is the caller graph for this function:

◆ GetGUID()

ObjectGuid Guild::GetGUID ( ) const
inline
726 { return ObjectGuid::Create<HighGuid::Guild>(m_id); }
ObjectGuid::LowType m_id
Definition: Guild.h:847
+ Here is the caller graph for this function:

◆ GetId()

ObjectGuid::LowType Guild::GetId ( ) const
inline
725 { return m_id; }
ObjectGuid::LowType m_id
Definition: Guild.h:847
+ Here is the caller graph for this function:

◆ GetInfo()

std::string const& Guild::GetInfo ( ) const
inline
730 { return m_info; }
std::string m_info
Definition: Guild.h:851
+ Here is the caller graph for this function:

◆ GetLeaderGUID()

ObjectGuid Guild::GetLeaderGUID ( ) const
inline
727 { return m_leaderGuid; }
ObjectGuid m_leaderGuid
Definition: Guild.h:849
+ Here is the caller graph for this function:

◆ GetLevel()

uint8 Guild::GetLevel ( ) const
inline
836 { return GUILD_OLD_MAX_LEVEL; }
Definition: Guild.h:59
+ Here is the caller graph for this function:

◆ GetMember() [1/3]

Member const* Guild::GetMember ( ObjectGuid const &  guid) const
inlineprivate
881  {
882  auto itr = m_members.find(guid);
883  return itr != m_members.end() ? itr->second : nullptr;
884  }
Members m_members
Definition: Guild.h:859
+ Here is the caller graph for this function:

◆ GetMember() [2/3]

Member* Guild::GetMember ( ObjectGuid const &  guid)
inlineprivate
887  {
888  auto itr = m_members.find(guid);
889  return itr != m_members.end() ? itr->second : nullptr;
890  }
Members m_members
Definition: Guild.h:859

◆ GetMember() [3/3]

Member* Guild::GetMember ( std::string const &  name)
inlineprivate
893  {
894  for (auto itr = m_members.begin(); itr != m_members.end(); ++itr)
895  if (itr->second->GetName() == name)
896  return itr->second;
897 
898  return nullptr;
899  }
Members m_members
Definition: Guild.h:859

◆ GetMembersCount()

uint32 Guild::GetMembersCount ( ) const
inline
823 { return uint32(m_members.size()); }
Members m_members
Definition: Guild.h:859
uint32_t uint32
Definition: Define.h:152
+ Here is the caller graph for this function:

◆ GetMOTD()

std::string const& Guild::GetMOTD ( ) const
inline
729 { return m_motd; }
std::string m_motd
Definition: Guild.h:850
+ Here is the caller graph for this function:

◆ GetName()

std::string const& Guild::GetName ( ) const
inline
728 { return m_name; }
std::string m_name
Definition: Guild.h:848
+ Here is the caller graph for this function:

◆ GetRankInfo() [1/2]

RankInfo const* Guild::GetRankInfo ( uint8  rankId) const
inlineprivate
870 { return rankId < _GetRanksSize() ? &m_ranks[rankId] : nullptr; }
Ranks m_ranks
Definition: Guild.h:858
uint8 _GetRanksSize() const
Definition: Guild.h:869
+ Here is the caller graph for this function:

◆ GetRankInfo() [2/2]

RankInfo* Guild::GetRankInfo ( uint8  rankId)
inlineprivate
871 { return rankId < _GetRanksSize() ? &m_ranks[rankId] : nullptr; }
Ranks m_ranks
Definition: Guild.h:858
uint8 _GetRanksSize() const
Definition: Guild.h:869

◆ HandleAcceptMember()

void Guild::HandleAcceptMember ( WorldSession session)
1751 {
1752  Player* player = session->GetPlayer();
1753  if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) &&
1754  player->GetTeam() != sCharacterCache->GetCharacterTeamByGuid(GetLeaderGUID()))
1755  return;
1756 
1757  CharacterDatabaseTransaction trans(nullptr);
1758  AddMember(trans, player->GetGUID());
1759 }
ObjectGuid GetLeaderGUID() const
Definition: Guild.h:727
#define sWorld
Definition: World.h:926
bool AddMember(CharacterDatabaseTransaction &trans, ObjectGuid guid, uint8 rankId=GUILD_RANK_NONE)
Definition: Guild.cpp:2676
#define sCharacterCache
Definition: CharacterCache.h:73
ObjectGuid const & GetGUID() const
Definition: Object.h:154
Player * GetPlayer() const
Definition: WorldSession.h:984
uint32 GetTeam() const
Definition: Player.h:2133
Definition: Player.h:1081
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:72
+ Here is the call graph for this function:

◆ HandleAddNewRank()

void Guild::HandleAddNewRank ( WorldSession session,
std::string const &  name 
)
1919 {
1920  uint8 size = _GetRanksSize();
1921  if (size >= GUILD_RANKS_MAX_COUNT)
1922  return;
1923 
1924  // Only leader can add new rank
1925  if (_IsLeader(session->GetPlayer()))
1926  {
1927  CharacterDatabaseTransaction trans(nullptr);
1929  {
1931  BroadcastPacket(eventPacket.Write());
1932  }
1933  }
1934 }
WorldPacket const * Write() override
Definition: GuildPackets.h:297
void BroadcastPacket(WorldPacket const *packet) const
Definition: Guild.cpp:2636
constexpr auto size(const C &c)
Definition: advstd.h:89
bool _IsLeader(Player *player) const
Definition: Guild.cpp:2988
Definition: Guild.h:84
bool _CreateRank(CharacterDatabaseTransaction &trans, std::string const &name, uint32 rights)
Definition: Guild.cpp:2950
Player * GetPlayer() const
Definition: WorldSession.h:984
Definition: Guild.h:85
uint8_t uint8
Definition: Define.h:154
Definition: GuildPackets.h:292
Definition: Guild.h:53
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:72
uint8 _GetRanksSize() const
Definition: Guild.h:869
+ Here is the call graph for this function:

◆ HandleBuyBankTab()

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

Hack to force client to update permissions

1638 {
1639  Player* player = session->GetPlayer();
1640  if (!player)
1641  return;
1642 
1643  Member const* member = GetMember(player->GetGUID());
1644  if (!member)
1645  return;
1646 
1648  return;
1649 
1650  if (tabId != _GetPurchasedTabsSize())
1651  return;
1652 
1653  if (tabId >= GUILD_BANK_MAX_TABS)
1654  return;
1655 
1656  // Do not get money for bank tabs that the GM bought, we had to buy them already.
1657  // This is just a speedup check, GetGuildBankTabPrice will return 0.
1658  if (tabId < GUILD_BANK_MAX_TABS - 2) // 7th tab is actually the 6th
1659  {
1660  int64 tabCost = GetGuildBankTabPrice(tabId) * GOLD;
1661  if (!player->HasEnoughMoney(tabCost)) // Should not happen, this is checked by client
1662  return;
1663 
1664  player->ModifyMoney(-tabCost);
1665  }
1666 
1668 
1670  BroadcastPacket(packet.Write());
1671 
1672  SendPermissions(session);
1673 }
int64_t int64
Definition: Define.h:147
WorldPacket const * Write() override
Definition: GuildPackets.h:382
Definition: Guild.h:48
void BroadcastPacket(WorldPacket const *packet) const
Definition: Guild.cpp:2636
ObjectGuid const & GetGUID() const
Definition: Object.h:154
bool HasEnoughMoney(uint64 amount) const
Definition: Player.h:1677
Definition: GuildPackets.h:377
void SendPermissions(WorldSession *session) const
Definition: Guild.cpp:2179
Definition: SharedDefines.h:250
Player * GetPlayer() const
Definition: WorldSession.h:984
bool ModifyMoney(int64 amount, bool sendError=true)
Definition: Player.cpp:24135
uint8 _GetPurchasedTabsSize() const
Definition: Guild.h:876
void _CreateNewBankTab()
Definition: Guild.cpp:2907
Member const * GetMember(ObjectGuid const &guid) const
Definition: Guild.h:880
uint64 GetGuildBankTabPrice(uint8 tabId)
Definition: Guild.cpp:48
Definition: Player.h:1081
+ Here is the call graph for this function:

◆ HandleDelete()

void Guild::HandleDelete ( WorldSession session)
2054 {
2055  // Only leader can disband guild
2056  if (_IsLeader(session->GetPlayer()))
2057  {
2058  Disband();
2059  TC_LOG_DEBUG("guild", "%s successfully deleted", GetGUID().ToString().c_str());
2060  delete this;
2061  }
2062 }
void Disband()
Definition: Guild.cpp:1208
string ToString(int i)
Definition: strutil.h:491
bool _IsLeader(Player *player) const
Definition: Guild.cpp:2988
Player * GetPlayer() const
Definition: WorldSession.h:984
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
ObjectGuid GetGUID() const
Definition: Guild.h:726
+ Here is the call graph for this function:

◆ HandleGetAchievementMembers()

void Guild::HandleGetAchievementMembers ( WorldSession session,
uint32  achievementId 
) const
1466 {
1467  m_achievementMgr.SendAchievementMembers(session->GetPlayer(), achievementId);
1468 }
Player * GetPlayer() const
Definition: WorldSession.h:984
GuildAchievementMgr m_achievementMgr
Definition: Guild.h:866
void SendAchievementMembers(Player *receiver, uint32 achievementId) const
Definition: AchievementMgr.cpp:925
+ Here is the call graph for this function:

◆ HandleGuildPartyRequest()

void Guild::HandleGuildPartyRequest ( WorldSession session) const
2065 {
2066  Player* player = session->GetPlayer();
2067  Group* group = player->GetGroup();
2068 
2069  // Make sure player is a member of the guild and that he is in a group.
2070  if (!IsMember(player->GetGUID()) || !group)
2071  return;
2072 
2073  WorldPackets::Guild::GuildPartyState partyStateResponse;
2074  partyStateResponse.InGuildParty = (player->GetMap()->GetOwnerGuildId(player->GetTeam()) == GetId());
2075  partyStateResponse.NumMembers = 0;
2076  partyStateResponse.NumRequired = 0;
2077  partyStateResponse.GuildXPEarnedMult = 0.0f;
2078  session->SendPacket(partyStateResponse.Write());
2079 
2080  TC_LOG_DEBUG("guild", "SMSG_GUILD_PARTY_STATE_RESPONSE [%s]", session->GetPlayerInfo().c_str());
2081 }
Group * GetGroup()
Definition: Player.h:2475
int32 NumRequired
Definition: GuildPackets.h:674
float GuildXPEarnedMult
Definition: GuildPackets.h:672
WorldPacket const * Write() override
Definition: GuildPackets.cpp:515
Map * GetMap() const
Definition: Object.h:535
ObjectGuid const & GetGUID() const
Definition: Object.h:154
int32 NumMembers
Definition: GuildPackets.h:673
ObjectGuid::LowType GetId() const
Definition: Guild.h:725
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:192
bool IsMember(ObjectGuid guid) const
Definition: Guild.cpp:2835
bool InGuildParty
Definition: GuildPackets.h:675
Definition: GuildPackets.h:665
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:208
Player * GetPlayer() const
Definition: WorldSession.h:984
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
virtual ObjectGuid::LowType GetOwnerGuildId(uint32=TEAM_OTHER) const
Definition: Map.h:513
uint32 GetTeam() const
Definition: Player.h:2133
Definition: Player.h:1081
Definition: Group.h:219
+ Here is the call graph for this function:

◆ HandleGuildRequestChallengeUpdate()

void Guild::HandleGuildRequestChallengeUpdate ( WorldSession session) const
Todo:
current count
2084 {
2086 
2087  for (int i = 0; i < GUILD_CHALLENGES_TYPES; ++i)
2088  updatePacket.CurrentCount[i] = int32(0);
2089 
2090  for (int i = 0; i < GUILD_CHALLENGES_TYPES; ++i)
2091  updatePacket.MaxCount[i] = int32(GuildChallengesMaxCount[i]);
2092 
2093  for (int i = 0; i < GUILD_CHALLENGES_TYPES; ++i)
2094  updatePacket.MaxLevelGold[i] = int32(GuildChallengeMaxLevelGoldReward[i]);
2095 
2096  for (int i = 0; i < GUILD_CHALLENGES_TYPES; ++i)
2097  updatePacket.Gold[i] = int32(GuildChallengeGoldReward[i]);
2098 
2099  session->SendPacket(updatePacket.Write());
2100 }
const uint32 GuildChallengeMaxLevelGoldReward[GUILD_CHALLENGES_TYPES]
Definition: Guild.h:245
WorldPacket const * Write() override
Definition: GuildPackets.cpp:918
const uint32 GuildChallengesMaxCount[GUILD_CHALLENGES_TYPES]
Definition: Guild.h:246
int32 MaxLevelGold[GUILD_CHALLENGES_TYPES]
Definition: GuildPackets.h:1148
Definition: GuildPackets.h:1138
int32 MaxCount[GUILD_CHALLENGES_TYPES]
Definition: GuildPackets.h:1146
int32_t int32
Definition: Define.h:148
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:208
#define GUILD_CHALLENGES_TYPES
Definition: Guild.h:242
int32 CurrentCount[GUILD_CHALLENGES_TYPES]
Definition: GuildPackets.h:1145
const uint32 GuildChallengeGoldReward[GUILD_CHALLENGES_TYPES]
Definition: Guild.h:244
int32 Gold[GUILD_CHALLENGES_TYPES]
Definition: GuildPackets.h:1147
+ Here is the call graph for this function:

◆ HandleInviteMember()

void Guild::HandleInviteMember ( WorldSession session,
std::string const &  name 
)
1676 {
1677  Player* pInvitee = ObjectAccessor::FindPlayerByName(name);
1678  if (!pInvitee)
1679  {
1681  return;
1682  }
1683 
1684  Player* player = session->GetPlayer();
1685  // Do not show invitations from ignored players
1686  if (pInvitee->GetSocial()->HasIgnore(player->GetGUID()))
1687  return;
1688 
1689  if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && pInvitee->GetTeam() != player->GetTeam())
1690  {
1692  return;
1693  }
1694 
1695  // Invited player cannot be in another guild
1696  if (pInvitee->GetGuildId())
1697  {
1699  return;
1700  }
1701 
1702  // Invited player cannot be invited
1703  if (pInvitee->GetGuildIdInvited())
1704  {
1706  return;
1707  }
1708 
1709  // Inviting player must have rights to invite
1710  if (!_HasRankRight(player, GR_RIGHT_INVITE))
1711  {
1713  return;
1714  }
1715 
1717 
1718  TC_LOG_DEBUG("guild", "Player %s invited %s to join his Guild", player->GetName().c_str(), name.c_str());
1719 
1720  pInvitee->SetGuildIdInvited(m_id);
1722 
1724 
1726  invite.GuildVirtualRealmAddress = GetVirtualRealmAddress();
1727  invite.GuildGUID = GetGUID();
1728 
1729  invite.EmblemStyle = uint32(m_emblemInfo.GetStyle());
1730  invite.EmblemColor = uint32(m_emblemInfo.GetColor());
1731  invite.BorderStyle = uint32(m_emblemInfo.GetBorderStyle());
1732  invite.BorderColor = uint32(m_emblemInfo.GetBorderColor());
1733  invite.Background = uint32(m_emblemInfo.GetBackgroundColor());
1734  invite.AchievementPoints = GetAchievementMgr().GetAchievementPoints();
1735 
1736  invite.InviterName = player->GetName();
1737  invite.GuildName = GetName();
1738 
1739  if (Guild* oldGuild = pInvitee->GetGuild())
1740  {
1741  invite.OldGuildGUID = oldGuild->GetGUID();
1742  invite.OldGuildName = oldGuild->GetName();
1743  invite.OldGuildVirtualRealmAddress = GetVirtualRealmAddress();
1744  }
1745 
1746  pInvitee->SendDirectMessage(invite.Write());
1747  TC_LOG_DEBUG("guild", "SMSG_GUILD_INVITE [%s]", pInvitee->GetName().c_str());
1748 }
Definition: Guild.h:88
uint32 GetStyle() const
Definition: Guild.h:259
static void SendCommandResult(WorldSession *session, GuildCommandType type, GuildCommandError errCode, std::string const &param="")
Definition: Guild.cpp:57
uint32 GetColor() const
Definition: Guild.h:260
EmblemInfo m_emblemInfo
Definition: Guild.h:854
uint32 GetBorderStyle() const
Definition: Guild.h:261
LowType GetCounter() const
Definition: ObjectGuid.h:273
ObjectGuid::LowType GetGuildIdInvited() const
Definition: Player.h:1916
Definition: Guild.h:111
#define sWorld
Definition: World.h:926
Definition: GuildPackets.h:211
bool _HasRankRight(Player const *player, uint32 right) const
Definition: Guild.cpp:2883
uint32 InviterVirtualRealmAddress
Definition: GuildPackets.h:228
Definition: Guild.h:190
PlayerSocial * GetSocial() const
Definition: Player.h:1141
ObjectGuid const & GetGUID() const
Definition: Object.h:154
std::string const & GetName() const
Definition: Object.h:467
std::string const & GetName() const
Definition: Guild.h:728
bool HasIgnore(ObjectGuid const &ignoreGuid)
Definition: SocialMgr.cpp:159
Guild * GetGuild()
Definition: Player.cpp:28375
void SendDirectMessage(WorldPacket const *data) const
Definition: Player.cpp:6155
uint32_t uint32
Definition: Define.h:152
uint32 GetBorderColor() const
Definition: Guild.h:262
TC_GAME_API Player * FindPlayerByName(std::string const &name)
Definition: ObjectAccessor.cpp:270
uint32 GetAchievementPoints() const
Definition: AchievementMgr.cpp:69
Player * GetPlayer() const
Definition: WorldSession.h:984
GuildAchievementMgr & GetAchievementMgr()
Definition: Guild.h:832
void _LogEvent(GuildEventLogTypes eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2=UI64LIT(0), uint8 newRank=0)
Definition: Guild.cpp:3153
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
ObjectGuid::LowType m_id
Definition: Guild.h:847
ObjectGuid::LowType GetGuildId() const
Definition: Player.h:1913
ObjectGuid GetGUID() const
Definition: Guild.h:726
uint32 GetVirtualRealmAddress()
Definition: World.cpp:3737
uint32 GetTeam() const
Definition: Player.h:2133
void SetGuildIdInvited(ObjectGuid::LowType GuildId)
Definition: Player.h:1912
uint32 GetBackgroundColor() const
Definition: Guild.h:263
Definition: Guild.h:305
Definition: Guild.h:130
Definition: Player.h:1081
+ Here is the call graph for this function:

◆ HandleLeaveMember()

void Guild::HandleLeaveMember ( WorldSession session)
1762 {
1763  Player* player = session->GetPlayer();
1764  bool disband = false;
1765 
1766  // If leader is leaving
1767  if (_IsLeader(player))
1768  {
1769  if (m_members.size() > 1)
1770  // Leader cannot leave if he is not the last member
1772  else
1773  {
1774  // Guild is disbanded if leader leaves.
1775  Disband();
1776  disband = true;
1777  }
1778  }
1779  else
1780  {
1783 
1784  CharacterDatabaseTransaction trans(nullptr);
1785  DeleteMember(trans, player->GetGUID(), false, false);
1786 
1788  }
1789 
1790  sCalendarMgr->RemovePlayerGuildEventsAndSignups(player->GetGUID(), GetId());
1791 
1792  if (disband)
1793  delete this;
1794 }
static void SendCommandResult(WorldSession *session, GuildCommandType type, GuildCommandError errCode, std::string const &param="")
Definition: Guild.cpp:57
void DeleteMember(CharacterDatabaseTransaction &trans, ObjectGuid guid, bool isDisbanding=false, bool isKicked=false, bool canDeleteGuild=false)
Definition: Guild.cpp:2762
#define sCalendarMgr
Definition: CalendarMgr.h:338
LowType GetCounter() const
Definition: ObjectGuid.h:273
void SendEventPlayerLeft(Member *leaver, Member *remover=nullptr, bool isRemoved=false) const
Definition: Guild.cpp:2329
void Disband()
Definition: Guild.cpp:1208
ObjectGuid const & GetGUID() const
Definition: Object.h:154
ObjectGuid::LowType GetId() const
Definition: Guild.h:725
bool _IsLeader(Player *player) const
Definition: Guild.cpp:2988
Members m_members
Definition: Guild.h:859
std::string m_name
Definition: Guild.h:848
Player * GetPlayer() const
Definition: WorldSession.h:984
void _LogEvent(GuildEventLogTypes eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2=UI64LIT(0), uint8 newRank=0)
Definition: Guild.cpp:3153
Member const * GetMember(ObjectGuid const &guid) const
Definition: Guild.h:880
Definition: Guild.h:195
Definition: Guild.h:112
Definition: Guild.h:130
Definition: Player.h:1081
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:72
+ Here is the call graph for this function:

◆ HandleMemberDepositMoney()

void Guild::HandleMemberDepositMoney ( WorldSession session,
uint64  amount,
bool  cashFlow = false 
)
1961 {
1962  // guild bank cannot have more than MAX_MONEY_AMOUNT
1963  amount = std::min(amount, MAX_MONEY_AMOUNT - m_bankMoney);
1964  if (!amount)
1965  return;
1966 
1967  Player* player = session->GetPlayer();
1968 
1969  // Call script after validation and before money transfer.
1970  sScriptMgr->OnGuildMemberDepositMoney(this, player, amount);
1971 
1972  CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
1973  _ModifyBankMoney(trans, amount, true);
1974  if (!cashFlow)
1975  {
1976  player->ModifyMoney(-int64(amount));
1977  player->SaveGoldToDB(trans);
1978  }
1979 
1981  CharacterDatabase.CommitTransaction(trans);
1982 
1984 
1986  {
1987  sLog->outCommand(player->GetSession()->GetAccountId(),
1988  "GM %s (Account: %u) deposit money (Amount: " UI64FMTD ") to guild bank (Guild ID " UI64FMTD ")",
1989  player->GetName().c_str(), player->GetSession()->GetAccountId(), amount, m_id);
1990  }
1991 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
uint64 const MAX_MONEY_AMOUNT
Definition: Player.cpp:141
void _LogBankEvent(CharacterDatabaseTransaction &trans, GuildBankEventLogTypes eventType, uint8 tabId, ObjectGuid::LowType playerGuid, uint64 itemOrMoney, uint16 itemStackCount=0, uint8 destTabId=0)
Definition: Guild.cpp:3163
int64_t int64
Definition: Define.h:147
WorldSession * GetSession() const
Definition: Player.h:2018
LowType GetCounter() const
Definition: ObjectGuid.h:273
#define sLog
Definition: Log.h:131
Definition: Guild.h:185
void SaveGoldToDB(CharacterDatabaseTransaction &trans) const
Definition: Player.cpp:20703
ObjectGuid const & GetGUID() const
Definition: Object.h:154
std::string const & GetName() const
Definition: Object.h:467
void SendEventBankMoneyChanged() const
Definition: Guild.cpp:2287
#define UI64FMTD
Definition: Define.h:139
Player * GetPlayer() const
Definition: WorldSession.h:984
bool ModifyMoney(int64 amount, bool sendError=true)
Definition: Player.cpp:24135
bool _ModifyBankMoney(CharacterDatabaseTransaction &trans, uint64 amount, bool add)
Definition: Guild.cpp:3008
ObjectGuid::LowType m_id
Definition: Guild.h:847
Definition: RBAC.h:64
uint8_t uint8
Definition: Define.h:154
#define sScriptMgr
Definition: ScriptMgr.h:1235
uint64 m_bankMoney
Definition: Guild.h:856
Definition: Guild.h:179
uint32 GetAccountId() const
Definition: WorldSession.h:979
bool HasPermission(uint32 permissionId)
Definition: WorldSession.cpp:1120
Definition: Player.h:1081
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:72
+ Here is the call graph for this function:

◆ HandleMemberLogout()

void Guild::HandleMemberLogout ( WorldSession session)
2040 {
2041  Player* player = session->GetPlayer();
2042  if (Member* member = GetMember(player->GetGUID()))
2043  {
2044  member->SetStats(player);
2045  member->UpdateLogoutTime();
2046  member->ResetFlags();
2047  }
2048 
2049  SendEventPresenceChanged(session, false, true);
2050  SaveToDB();
2051 }
ObjectGuid const & GetGUID() const
Definition: Object.h:154
void SaveToDB()
Definition: Guild.cpp:1262
Player * GetPlayer() const
Definition: WorldSession.h:984
Member const * GetMember(ObjectGuid const &guid) const
Definition: Guild.h:880
Definition: Player.h:1081
void SendEventPresenceChanged(WorldSession *session, bool loggedOn, bool broadcast=false) const
Definition: Guild.cpp:2347
+ Here is the call graph for this function:

◆ HandleMemberWithdrawMoney()

bool Guild::HandleMemberWithdrawMoney ( WorldSession session,
uint64  amount,
bool  repair = false 
)
1994 {
1995  // clamp amount to MAX_MONEY_AMOUNT, Players can't hold more than that anyway
1996  amount = std::min(amount, MAX_MONEY_AMOUNT);
1997 
1998  if (m_bankMoney < amount) // Not enough money in bank
1999  return false;
2000 
2001  Player* player = session->GetPlayer();
2002 
2003  Member* member = GetMember(player->GetGUID());
2004  if (!member)
2005  return false;
2006 
2008  return false;
2009 
2010  if (_GetMemberRemainingMoney(member) < int64(amount)) // Check if we have enough slot/money today
2011  return false;
2012 
2013  // Call script after validation and before money transfer.
2014  sScriptMgr->OnGuildMemberWitdrawMoney(this, player, amount, repair);
2015 
2016  CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
2017  // Add money to player (if required)
2018  if (!repair)
2019  {
2020  if (!player->ModifyMoney(amount))
2021  return false;
2022 
2023  player->SaveGoldToDB(trans);
2024  }
2025 
2026  // Update remaining money amount
2027  member->UpdateBankMoneyWithdrawValue(trans, amount);
2028  // Remove money from bank
2029  _ModifyBankMoney(trans, amount, false);
2030 
2031  // Log guild bank event
2033  CharacterDatabase.CommitTransaction(trans);
2034 
2036  return true;
2037 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
uint64 const MAX_MONEY_AMOUNT
Definition: Player.cpp:141
void _LogBankEvent(CharacterDatabaseTransaction &trans, GuildBankEventLogTypes eventType, uint8 tabId, ObjectGuid::LowType playerGuid, uint64 itemOrMoney, uint16 itemStackCount=0, uint8 destTabId=0)
Definition: Guild.cpp:3163
Definition: Guild.h:102
int64_t int64
Definition: Define.h:147
LowType GetCounter() const
Definition: ObjectGuid.h:273
Definition: Guild.h:181
void SaveGoldToDB(CharacterDatabaseTransaction &trans) const
Definition: Player.cpp:20703
Definition: Guild.h:180
bool _HasRankRight(Player const *player, uint32 right) const
Definition: Guild.cpp:2883
ObjectGuid const & GetGUID() const
Definition: Object.h:154
void SendEventBankMoneyChanged() const
Definition: Guild.cpp:2287
Definition: Guild.h:103
Player * GetPlayer() const
Definition: WorldSession.h:984
bool ModifyMoney(int64 amount, bool sendError=true)
Definition: Player.cpp:24135
bool _ModifyBankMoney(CharacterDatabaseTransaction &trans, uint64 amount, bool add)
Definition: Guild.cpp:3008
int64 _GetMemberRemainingMoney(Member const *member) const
Definition: Guild.cpp:3116
uint8_t uint8
Definition: Define.h:154
#define sScriptMgr
Definition: ScriptMgr.h:1235
Member const * GetMember(ObjectGuid const &guid) const
Definition: Guild.h:880
uint64 m_bankMoney
Definition: Guild.h:856
Definition: Player.h:1081
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:72
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandleNewsSetSticky()

void Guild::HandleNewsSetSticky ( WorldSession session,
uint32  newsId,
bool  sticky 
) const
3531 {
3532  GuildLog* logs = m_newsLog->GetGuildLog();
3533  GuildLog::iterator itr = logs->begin();
3534  while (itr != logs->end() && (*itr)->GetGUID() != newsId)
3535  ++itr;
3536 
3537  if (itr == logs->end())
3538  {
3539  TC_LOG_DEBUG("guild", "HandleNewsSetSticky: [%s] requested unknown newsId %u - Sticky: %u",
3540  session->GetPlayerInfo().c_str(), newsId, sticky);
3541  return;
3542  }
3543 
3544  NewsLogEntry* news = static_cast<NewsLogEntry*>(*itr);
3545  news->SetSticky(sticky);
3546 
3547  TC_LOG_DEBUG("guild", "HandleNewsSetSticky: [%s] changed newsId %u sticky to %u",
3548  session->GetPlayerInfo().c_str(), newsId, sticky);
3549 
3550  WorldPackets::Guild::GuildNews newsPacket;
3551  newsPacket.NewsEvents.reserve(1);
3552  news->WritePacket(newsPacket);
3553  session->SendPacket(newsPacket.Write());
3554 }
Definition: GuildPackets.h:1090
GuildLog * GetGuildLog()
Definition: Guild.h:532
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:192
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:208
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
std::list< LogEntry * > GuildLog
Definition: Guild.h:516
std::vector< GuildNewsEvent > NewsEvents
Definition: GuildPackets.h:1097
LogHolder * m_newsLog
Definition: Guild.h:865
+ Here is the call graph for this function:

◆ HandleRemoveMember()

void Guild::HandleRemoveMember ( WorldSession session,
ObjectGuid  guid 
)
1797 {
1798  Player* player = session->GetPlayer();
1799 
1800  // Player must have rights to remove members
1801  if (!_HasRankRight(player, GR_RIGHT_REMOVE))
1803  else if (Member* member = GetMember(guid))
1804  {
1805  std::string name = member->GetName();
1806 
1807  // Guild masters cannot be removed
1808  if (member->IsRank(GR_GUILDMASTER))
1810  // Do not allow to remove player with the same rank or higher
1811  else
1812  {
1813  Member* memberMe = GetMember(player->GetGUID());
1814  if (!memberMe || member->IsRankNotLower(memberMe->GetRankId()))
1816  else
1817  {
1819  SendEventPlayerLeft(member, memberMe, true);
1820 
1821  // After call to DeleteMember pointer to member becomes invalid
1822  CharacterDatabaseTransaction trans(nullptr);
1823  DeleteMember(trans, guid, false, true);
1824 
1826  }
1827  }
1828  }
1829 }
Definition: Guild.h:72
static void SendCommandResult(WorldSession *session, GuildCommandType type, GuildCommandError errCode, std::string const &param="")
Definition: Guild.cpp:57
void DeleteMember(CharacterDatabaseTransaction &trans, ObjectGuid guid, bool isDisbanding=false, bool isKicked=false, bool canDeleteGuild=false)
Definition: Guild.cpp:2762
LowType GetCounter() const
Definition: ObjectGuid.h:273
void SendEventPlayerLeft(Member *leaver, Member *remover=nullptr, bool isRemoved=false) const
Definition: Guild.cpp:2329
bool _HasRankRight(Player const *player, uint32 right) const
Definition: Guild.cpp:2883
ObjectGuid const & GetGUID() const
Definition: Object.h:154
Player * GetPlayer() const
Definition: WorldSession.h:984
void _LogEvent(GuildEventLogTypes eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2=UI64LIT(0), uint8 newRank=0)
Definition: Guild.cpp:3153
Definition: Guild.h:116
Definition: Guild.h:194
Member const * GetMember(ObjectGuid const &guid) const
Definition: Guild.h:880
Definition: Guild.h:130
Definition: Player.h:1081
Definition: Guild.h:89
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:72
+ Here is the call graph for this function:

◆ HandleRemoveRank()

void Guild::HandleRemoveRank ( WorldSession session,
uint8  rankId 
)
1937 {
1938  // Cannot remove rank if total count is minimum allowed by the client or is not leader
1939  if (_GetRanksSize() <= GUILD_RANKS_MIN_COUNT || rankId >= _GetRanksSize() || !_IsLeader(session->GetPlayer()))
1940  return;
1941 
1942  // Delete bank rights for rank
1944  stmt->setUInt64(0, m_id);
1945  stmt->setUInt8(1, rankId);
1946  CharacterDatabase.Execute(stmt);
1947 
1948  // Delete rank
1949  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_RANK);
1950  stmt->setUInt64(0, m_id);
1951  stmt->setUInt8(1, rankId);
1952  CharacterDatabase.Execute(stmt);
1953 
1954  m_ranks.erase(m_ranks.begin() + rankId);
1955 
1957  BroadcastPacket(eventPacket.Write());
1958 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
WorldPacket const * Write() override
Definition: GuildPackets.h:297
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:100
Definition: DatabaseEnvFwd.h:40
void BroadcastPacket(WorldPacket const *packet) const
Definition: Guild.cpp:2636
Definition: Guild.h:52
bool _IsLeader(Player *player) const
Definition: Guild.cpp:2988
Definition: CharacterDatabase.h:226
Definition: CharacterDatabase.h:216
Ranks m_ranks
Definition: Guild.h:858
Player * GetPlayer() const
Definition: WorldSession.h:984
ObjectGuid::LowType m_id
Definition: Guild.h:847
Definition: GuildPackets.h:292
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
uint8 _GetRanksSize() const
Definition: Guild.h:869
+ Here is the call graph for this function:

◆ HandleRoster()

void Guild::HandleRoster ( WorldSession session)
1324 {
1326 
1328  roster.CreateDate = uint32(m_createdDate);
1329  roster.GuildFlags = 0;
1330 
1331  roster.MemberData.reserve(m_members.size());
1332 
1333  for (auto itr : m_members)
1334  {
1335  Member* member = itr.second;
1336 
1338 
1339  memberData.Guid = member->GetGUID();
1340  memberData.RankID = int32(member->GetRankId());
1341  memberData.AreaID = int32(member->GetZoneId());
1342  memberData.PersonalAchievementPoints = int32(member->GetAchievementPoints());
1343  memberData.GuildReputation = int32(member->GetTotalReputation());
1344  memberData.LastSave = member->GetInactiveDays();
1345 
1346  //GuildRosterProfessionData
1347 
1349  memberData.Status = member->GetFlags();
1350  memberData.Level = member->GetLevel();
1351  memberData.ClassID = member->GetClass();
1352  memberData.Gender = member->GetGender();
1353 
1354  memberData.Authenticated = false;
1355  memberData.SorEligible = false;
1356 
1357  memberData.Name = member->GetName();
1358  memberData.Note = member->GetPublicNote();
1359  memberData.OfficerNote = member->GetOfficerNote();
1360 
1361  roster.MemberData.push_back(memberData);
1362  }
1363 
1364  roster.WelcomeText = m_motd;
1365  roster.InfoText = m_info;
1366 
1367  TC_LOG_DEBUG("guild", "SMSG_GUILD_ROSTER [%s]", session->GetPlayerInfo().c_str());
1368  session->SendPacket(roster.Write());
1369 }
std::string Name
Definition: GuildPackets.h:113
std::string InfoText
Definition: GuildPackets.h:136
std::string WelcomeText
Definition: GuildPackets.h:135
bool SorEligible
Definition: GuildPackets.h:122
int32 GuildFlags
Definition: GuildPackets.h:139
int32 RankID
Definition: GuildPackets.h:107
uint32 m_accountsNumber
Definition: Guild.h:855
Definition: GuildPackets.h:102
time_t m_createdDate
Definition: Guild.h:852
uint8 Status
Definition: GuildPackets.h:117
std::string OfficerNote
Definition: GuildPackets.h:116
int32 GuildReputation
Definition: GuildPackets.h:110
int32 NumAccounts
Definition: GuildPackets.h:138
uint32 VirtualRealmAddress
Definition: GuildPackets.h:114
std::string m_motd
Definition: Guild.h:850
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:192
std::vector< GuildRosterMemberData > MemberData
Definition: GuildPackets.h:134
uint8 Level
Definition: GuildPackets.h:118
WorldPacket const * Write() override
Definition: GuildPackets.cpp:65
int32 PersonalAchievementPoints
Definition: GuildPackets.h:109
float LastSave
Definition: GuildPackets.h:112
Members m_members
Definition: Guild.h:859
int32_t int32
Definition: Define.h:148
ObjectGuid Guid
Definition: GuildPackets.h:104
uint32_t uint32
Definition: Define.h:152
Definition: GuildPackets.h:127
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:208
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
uint8 ClassID
Definition: GuildPackets.h:119
uint8 Gender
Definition: GuildPackets.h:120
uint32 GetVirtualRealmAddress()
Definition: World.cpp:3737
std::string Note
Definition: GuildPackets.h:115
uint32 CreateDate
Definition: GuildPackets.h:137
int32 AreaID
Definition: GuildPackets.h:108
std::string m_info
Definition: Guild.h:851
bool Authenticated
Definition: GuildPackets.h:121
+ Here is the call graph for this function:

◆ HandleSetAchievementTracking()

void Guild::HandleSetAchievementTracking ( WorldSession session,
uint32 const *  achievementIdsBegin,
uint32 const *  achievementIdsEnd 
)
1434 {
1435  Player* player = session->GetPlayer();
1436 
1437  if (Member* member = GetMember(player->GetGUID()))
1438  {
1439  std::set<uint32> criteriaIds;
1440 
1441  for (uint32 const* achievementIdItr = achievementIdsBegin; achievementIdItr != achievementIdsEnd; ++achievementIdItr)
1442  {
1443  uint32 achievementId = *achievementIdItr;
1444  if (AchievementEntry const* achievement = sAchievementStore.LookupEntry(achievementId))
1445  {
1446  if (!(achievement->Flags & ACHIEVEMENT_FLAG_GUILD) || m_achievementMgr.HasAchieved(achievementId))
1447  continue;
1448 
1449  if (CriteriaTree const* tree = sCriteriaMgr->GetCriteriaTree(achievement->CriteriaTree))
1450  {
1451  CriteriaMgr::WalkCriteriaTree(tree, [&criteriaIds](CriteriaTree const* node)
1452  {
1453  if (node->Criteria)
1454  criteriaIds.insert(node->Criteria->ID);
1455  });
1456  }
1457  }
1458  }
1459 
1460  member->SetTrackedCriteriaIds(std::move(criteriaIds));
1461  m_achievementMgr.SendAllTrackedCriterias(player, member->GetTrackedCriteriaIds());
1462  }
1463 }
Definition: CriteriaHandler.h:67
Definition: DBCEnums.h:98
ObjectGuid const & GetGUID() const
Definition: Object.h:154
#define sCriteriaMgr
Definition: CriteriaHandler.h:419
Definition: DB2Structure.h:28
struct Criteria const * Criteria
Definition: CriteriaHandler.h:74
bool HasAchieved(uint32 achievementId) const
Definition: AchievementMgr.cpp:64
uint32_t uint32
Definition: Define.h:152
static void WalkCriteriaTree(CriteriaTree const *tree, Func const &func)
Definition: CriteriaHandler.h:384
uint32 ID
Definition: CriteriaHandler.h:58
Player * GetPlayer() const
Definition: WorldSession.h:984
GuildAchievementMgr m_achievementMgr
Definition: Guild.h:866
void SendAllTrackedCriterias(Player *receiver, std::set< uint32 > const &trackedCriterias) const
Definition: AchievementMgr.cpp:899
Member const * GetMember(ObjectGuid const &guid) const
Definition: Guild.h:880
DB2Storage< AchievementEntry > sAchievementStore("Achievement.db2", AchievementLoadInfo::Instance())
Definition: Player.h:1081
+ Here is the call graph for this function:

◆ HandleSetBankTabInfo()

void Guild::HandleSetBankTabInfo ( WorldSession session,
uint8  tabId,
std::string const &  name,
std::string const &  icon 
)
1577 {
1578  BankTab* tab = GetBankTab(tabId);
1579  if (!tab)
1580  {
1581  TC_LOG_ERROR("guild", "Guild::HandleSetBankTabInfo: Player %s trying to change bank tab info from unexisting tab %d.",
1582  session->GetPlayerInfo().c_str(), tabId);
1583  return;
1584  }
1585 
1586  tab->SetInfo(name, icon);
1587 
1589  packet.Tab = tabId;
1590  packet.Name = name;
1591  packet.Icon = icon;
1592  BroadcastPacket(packet.Write());
1593 }
Definition: GuildPackets.h:385
std::string Name
Definition: GuildPackets.h:393
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:186
BankTab * GetBankTab(uint8 tabId)
Definition: Guild.h:877
std::string Icon
Definition: GuildPackets.h:392
void BroadcastPacket(WorldPacket const *packet) const
Definition: Guild.cpp:2636
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:192
WorldPacket const * Write() override
Definition: GuildPackets.cpp:356
int32 Tab
Definition: GuildPackets.h:394
+ Here is the call graph for this function:

◆ HandleSetEmblem()

void Guild::HandleSetEmblem ( WorldSession session,
EmblemInfo const &  emblemInfo 
)
1513 {
1514  Player* player = session->GetPlayer();
1515  if (!_IsLeader(player))
1516  SendSaveEmblemResult(session, ERR_GUILDEMBLEM_NOTGUILDMASTER); // "Only guild leaders can create emblems."
1517  else if (!player->HasEnoughMoney(uint64(EMBLEM_PRICE)))
1518  SendSaveEmblemResult(session, ERR_GUILDEMBLEM_NOTENOUGHMONEY); // "You can't afford to do that."
1519  else
1520  {
1521  player->ModifyMoney(-int64(EMBLEM_PRICE));
1522 
1523  m_emblemInfo = emblemInfo;
1525 
1526  SendSaveEmblemResult(session, ERR_GUILDEMBLEM_SUCCESS); // "Guild Emblem saved."
1527 
1529  }
1530 }
static ObjectGuid const Empty
Definition: ObjectGuid.h:255
int64_t int64
Definition: Define.h:147
EmblemInfo m_emblemInfo
Definition: Guild.h:854
void SaveToDB(ObjectGuid::LowType guildId) const
Definition: Guild.cpp:756
bool HasEnoughMoney(uint64 amount) const
Definition: Player.h:1677
static void SendSaveEmblemResult(WorldSession *session, GuildEmblemError errCode)
Definition: Guild.cpp:69
bool _IsLeader(Player *player) const
Definition: Guild.cpp:2988
uint64_t uint64
Definition: Define.h:151
Player * GetPlayer() const
Definition: WorldSession.h:984
bool ModifyMoney(int64 amount, bool sendError=true)
Definition: Player.cpp:24135
ObjectGuid::LowType m_id
Definition: Guild.h:847
void SendQueryResponse(WorldSession *session, ObjectGuid const &playerGuid)
Definition: Guild.cpp:1371
uint32 const EMBLEM_PRICE
Definition: Guild.cpp:46
Definition: Player.h:1081
+ Here is the call graph for this function:

◆ HandleSetInfo()

void Guild::HandleSetInfo ( WorldSession session,
std::string const &  info 
)
1494 {
1495  if (m_info == info)
1496  return;
1497 
1498  // Player must have rights to set guild's info
1500  {
1501  m_info = info;
1502 
1503  sScriptMgr->OnGuildInfoChanged(this, info);
1504 
1506  stmt->setString(0, info);
1507  stmt->setUInt64(1, m_id);
1508  CharacterDatabase.Execute(stmt);
1509  }
1510 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: CharacterDatabase.h:237
Definition: DatabaseEnvFwd.h:40
bool _HasRankRight(Player const *player, uint32 right) const
Definition: Guild.cpp:2883
Definition: Guild.h:100
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:180
Player * GetPlayer() const
Definition: WorldSession.h:984
ObjectGuid::LowType m_id
Definition: Guild.h:847
#define sScriptMgr
Definition: ScriptMgr.h:1235
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
std::string m_info
Definition: Guild.h:851
+ Here is the call graph for this function:

◆ HandleSetMemberNote()

void Guild::HandleSetMemberNote ( WorldSession session,
std::string const &  note,
ObjectGuid  guid,
bool  isPublic 
)
1596 {
1597  // Player must have rights to set public/officer note
1598  if (!_HasRankRight(session->GetPlayer(), isPublic ? GR_RIGHT_EDIT_PUBLIC_NOTE : GR_RIGHT_EOFFNOTE))
1600  else if (Member* member = GetMember(guid))
1601  {
1602  if (isPublic)
1603  member->SetPublicNote(note);
1604  else
1605  member->SetOfficerNote(note);
1606 
1608  updateNote.Member = guid;
1609  updateNote.IsPublic = isPublic;
1610  updateNote.Note = note;
1611  BroadcastPacket(updateNote.Write());
1612  }
1613 }
std::string Note
Definition: GuildPackets.h:578
Definition: Guild.h:122
ObjectGuid Member
Definition: GuildPackets.h:576
static void SendCommandResult(WorldSession *session, GuildCommandType type, GuildCommandError errCode, std::string const &param="")
Definition: Guild.cpp:57
Definition: GuildPackets.h:569
void BroadcastPacket(WorldPacket const *packet) const
Definition: Guild.cpp:2636
bool _HasRankRight(Player const *player, uint32 right) const
Definition: Guild.cpp:2883
WorldPacket const * Write() override
Definition: GuildPackets.cpp:467
Definition: Guild.h:99
Definition: Guild.h:97
Player * GetPlayer() const
Definition: WorldSession.h:984
Member const * GetMember(ObjectGuid const &guid) const
Definition: Guild.h:880
bool IsPublic
0 == Officer, 1 == Public
Definition: GuildPackets.h:577
+ Here is the call graph for this function:

◆ HandleSetMemberRank()

void Guild::HandleSetMemberRank ( WorldSession session,
ObjectGuid  guid,
ObjectGuid  setterGuid,
uint32  rank 
)
1887 {
1888  Player* player = session->GetPlayer();
1889  Member* member = GetMember(targetGuid);
1890  if (!member)
1891  return;
1894 
1895  if (rank > member->GetRankId())
1896  {
1897  rights = GR_RIGHT_DEMOTE;
1899  }
1900 
1901  // Promoted player must be a member of guild
1902  if (!_HasRankRight(player, rights))
1903  {
1904  SendCommandResult(session, type, ERR_GUILD_PERMISSIONS);
1905  return;
1906  }
1907 
1908  // Player cannot promote himself
1909  if (member->IsSamePlayer(player->GetGUID()))
1910  {
1911  SendCommandResult(session, type, ERR_GUILD_NAME_INVALID);
1912  return;
1913  }
1914 
1915  SendGuildRanksUpdate(setterGuid, targetGuid, rank);
1916 }
static void SendCommandResult(WorldSession *session, GuildCommandType type, GuildCommandError errCode, std::string const &param="")
Definition: Guild.cpp:57
Definition: Guild.h:91
bool _HasRankRight(Player const *player, uint32 right) const
Definition: Guild.cpp:2883
ObjectGuid const & GetGUID() const
Definition: Object.h:154
GuildRankRights
Definition: Guild.h:81
Definition: Guild.h:92
void SendGuildRanksUpdate(ObjectGuid setterGuid, ObjectGuid targetGuid, uint32 rank)
Definition: Guild.cpp:3474
Player * GetPlayer() const
Definition: WorldSession.h:984
Definition: Guild.h:115
Definition: Guild.h:114
Member const * GetMember(ObjectGuid const &guid) const
Definition: Guild.h:880
GuildCommandType
Definition: Guild.h:108
Definition: Player.h:1081
+ Here is the call graph for this function:

◆ HandleSetMOTD()

void Guild::HandleSetMOTD ( WorldSession session,
std::string const &  motd 
)
1471 {
1472  if (m_motd == motd)
1473  return;
1474 
1475  // Player must have rights to set MOTD
1476  if (!_HasRankRight(session->GetPlayer(), GR_RIGHT_SETMOTD))
1478  else
1479  {
1480  m_motd = motd;
1481 
1482  sScriptMgr->OnGuildMOTDChanged(this, motd);
1483 
1485  stmt->setString(0, motd);
1486  stmt->setUInt64(1, m_id);
1487  CharacterDatabase.Execute(stmt);
1488 
1489  SendEventMOTD(session, true);
1490  }
1491 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
static void SendCommandResult(WorldSession *session, GuildCommandType type, GuildCommandError errCode, std::string const &param="")
Definition: Guild.cpp:57
Definition: Guild.h:118
Definition: DatabaseEnvFwd.h:40
bool _HasRankRight(Player const *player, uint32 right) const
Definition: Guild.cpp:2883
std::string m_motd
Definition: Guild.h:850
void SendEventMOTD(WorldSession *session, bool broadcast=false) const
Definition: Guild.cpp:2294
Definition: Guild.h:96
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:180
Player * GetPlayer() const
Definition: WorldSession.h:984
ObjectGuid::LowType m_id
Definition: Guild.h:847
Definition: CharacterDatabase.h:236
#define sScriptMgr
Definition: ScriptMgr.h:1235
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
+ Here is the call graph for this function:

◆ HandleSetNewGuildMaster()

void Guild::HandleSetNewGuildMaster ( WorldSession session,
std::string const &  name,
bool  isSelfPromote 
)
1533 {
1534  Player* player = session->GetPlayer();
1535 
1536  Member* oldGuildMaster = GetMember(GetLeaderGUID());
1537  ASSERT(oldGuildMaster);
1538 
1539  Member* newGuildMaster;
1540 
1541  if (isSelfPromote)
1542  {
1543  newGuildMaster = GetMember(player->GetGUID());
1544  if (!newGuildMaster)
1545  return;
1546 
1547  if (!newGuildMaster->IsRankNotLower(GR_MEMBER) || uint32(oldGuildMaster->GetInactiveDays()) < GUILD_MASTER_DETHRONE_INACTIVE_DAYS)
1548  {
1550  return;
1551  }
1552  }
1553  else
1554  {
1555  if (!_IsLeader(player))
1556  {
1558  return;
1559  }
1560 
1561  newGuildMaster = GetMember(name);
1562  if (!newGuildMaster)
1563  return;
1564  }
1565 
1566  CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
1567 
1568  _SetLeader(trans, newGuildMaster);
1569  oldGuildMaster->ChangeRank(trans, GR_INITIATE);
1570 
1571  SendEventNewLeader(newGuildMaster, oldGuildMaster, isSelfPromote);
1572 
1573  CharacterDatabase.CommitTransaction(trans);
1574 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
static void SendCommandResult(WorldSession *session, GuildCommandType type, GuildCommandError errCode, std::string const &param="")
Definition: Guild.cpp:57
ObjectGuid GetLeaderGUID() const
Definition: Guild.h:727
void SendEventNewLeader(Member *newLeader, Member *oldLeader, bool isSelfPromoted=false) const
Definition: Guild.cpp:2308
ObjectGuid const & GetGUID() const
Definition: Object.h:154
bool _IsLeader(Player *player) const
Definition: Guild.cpp:2988
uint32_t uint32
Definition: Define.h:152
Definition: Guild.h:75
Definition: Guild.h:76
Player * GetPlayer() const
Definition: WorldSession.h:984
void _SetLeader(CharacterDatabaseTransaction &trans, Member *leader)
Definition: Guild.cpp:3027
#define ASSERT
Definition: Errors.h:61
Definition: Guild.h:117
Member const * GetMember(ObjectGuid const &guid) const
Definition: Guild.h:880
Definition: Player.h:1081
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:72
+ Here is the call graph for this function:

◆ HandleSetRankInfo()

void Guild::HandleSetRankInfo ( WorldSession session,
uint8  rankId,
std::string const &  name,
uint32  rights,
uint32  moneyPerDay,
GuildBankRightsAndSlotsVec const &  rightsAndSlots 
)
1616 {
1617  // Only leader can modify ranks
1618  if (!_IsLeader(session->GetPlayer()))
1620  else if (RankInfo* rankInfo = GetRankInfo(rankId))
1621  {
1622  TC_LOG_DEBUG("guild", "Changed RankName to '%s', rights to 0x%08X", name.c_str(), rights);
1623 
1624  rankInfo->SetName(name);
1625  rankInfo->SetRights(rights);
1626  _SetRankBankMoneyPerDay(rankId, moneyPerDay * GOLD);
1627 
1628  for (auto itr = rightsAndSlots.begin(); itr != rightsAndSlots.end(); ++itr)
1629  _SetRankBankTabRightsAndSlots(rankId, *itr);
1630 
1632  packet.RankID = rankId;
1633  BroadcastPacket(packet.Write());
1634  }
1635 }
static void SendCommandResult(WorldSession *session, GuildCommandType type, GuildCommandError errCode, std::string const &param="")
Definition: Guild.cpp:57
void _SetRankBankTabRightsAndSlots(uint8 rankId, GuildBankRightsAndSlots rightsAndSlots, bool saveToDB=true)
Definition: Guild.cpp:3054
RankInfo const * GetRankInfo(uint8 rankId) const
Definition: Guild.h:870
Definition: GuildPackets.h:282
WorldPacket const * Write() override
Definition: GuildPackets.cpp:247
void BroadcastPacket(WorldPacket const *packet) const
Definition: Guild.cpp:2636
bool _IsLeader(Player *player) const
Definition: Guild.cpp:2988
Definition: Guild.h:121
Definition: SharedDefines.h:250
Player * GetPlayer() const
Definition: WorldSession.h:984
int32 RankID
Definition: GuildPackets.h:289
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
void _SetRankBankMoneyPerDay(uint8 rankId, uint32 moneyPerDay)
Definition: Guild.cpp:3048
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandleUpdateMemberRank()

void Guild::HandleUpdateMemberRank ( WorldSession session,
ObjectGuid  guid,
bool  demote 
)
1832 {
1833  Player* player = session->GetPlayer();
1835  // Player must have rights to promote
1836  if (!_HasRankRight(player, demote ? GR_RIGHT_DEMOTE : GR_RIGHT_PROMOTE))
1837  SendCommandResult(session, type, ERR_GUILD_PERMISSIONS);
1838  // Promoted player must be a member of guild
1839  else if (Member* member = GetMember(guid))
1840  {
1841  std::string name = member->GetName();
1842  // Player cannot promote himself
1843  if (member->IsSamePlayer(player->GetGUID()))
1844  {
1845  SendCommandResult(session, type, ERR_GUILD_NAME_INVALID);
1846  return;
1847  }
1848 
1849  Member const* memberMe = GetMember(player->GetGUID());
1850  ASSERT(memberMe);
1851  uint8 rankId = memberMe->GetRankId();
1852  if (demote)
1853  {
1854  // Player can demote only lower rank members
1855  if (member->IsRankNotLower(rankId))
1856  {
1857  SendCommandResult(session, type, ERR_GUILD_RANK_TOO_HIGH_S, name);
1858  return;
1859  }
1860  // Lowest rank cannot be demoted
1861  if (member->GetRankId() >= _GetLowestRankId())
1862  {
1863  SendCommandResult(session, type, ERR_GUILD_RANK_TOO_LOW_S, name);
1864  return;
1865  }
1866  }
1867  else
1868  {
1869  // Allow to promote only to lower rank than member's rank
1870  // member->GetRankId() + 1 is the highest rank that current player can promote to
1871  if (member->IsRankNotLower(rankId + 1))
1872  {
1873  SendCommandResult(session, type, ERR_GUILD_RANK_TOO_HIGH_S, name);
1874  return;
1875  }
1876  }
1877 
1878  uint32 newRankId = member->GetRankId() + (demote ? 1 : -1);
1879  CharacterDatabaseTransaction trans(nullptr);
1880  member->ChangeRank(trans, newRankId);
1881  _LogEvent(demote ? GUILD_EVENT_LOG_DEMOTE_PLAYER : GUILD_EVENT_LOG_PROMOTE_PLAYER, player->GetGUID().GetCounter(), member->GetGUID().GetCounter(), newRankId);
1882  //_BroadcastEvent(demote ? GE_DEMOTION : GE_PROMOTION, ObjectGuid::Empty, player->GetName().c_str(), name.c_str(), _GetRankName(newRankId).c_str());
1883  }
1884 }
static void SendCommandResult(WorldSession *session, GuildCommandType type, GuildCommandError errCode, std::string const &param="")
Definition: Guild.cpp:57
Definition: Guild.h:91
LowType GetCounter() const
Definition: ObjectGuid.h:273
Definition: Guild.h:193
Definition: Guild.h:192
bool _HasRankRight(Player const *player, uint32 right) const
Definition: Guild.cpp:2883
ObjectGuid const & GetGUID() const
Definition: Object.h:154
Definition: Guild.h:92
uint32_t uint32
Definition: Define.h:152
Player * GetPlayer() const
Definition: WorldSession.h:984
void _LogEvent(GuildEventLogTypes eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2=UI64LIT(0), uint8 newRank=0)
Definition: Guild.cpp:3153
Definition: Guild.h:115
Definition: Guild.h:114
uint8_t uint8
Definition: Define.h:154
#define ASSERT
Definition: Errors.h:61
Member const * GetMember(ObjectGuid const &guid) const
Definition: Guild.h:880
GuildCommandType
Definition: Guild.h:108
uint8 _GetLowestRankId() const
Definition: Guild.h:874
Definition: Player.h:1081
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:72
+ Here is the call graph for this function:

◆ HasAchieved()

bool Guild::HasAchieved ( uint32  achievementId) const
3521 {
3522  return m_achievementMgr.HasAchieved(achievementId);
3523 }
bool HasAchieved(uint32 achievementId) const
Definition: AchievementMgr.cpp:64
GuildAchievementMgr m_achievementMgr
Definition: Guild.h:866
+ Here is the call graph for this function:

◆ IsMember()

bool Guild::IsMember ( ObjectGuid  guid) const
2836 {
2837  Members::const_iterator itr = m_members.find(guid);
2838  return itr != m_members.end();
2839 }
Members m_members
Definition: Guild.h:859
+ Here is the caller graph for this function:

◆ LoadBankEventLogFromDB()

bool Guild::LoadBankEventLogFromDB ( Field fields)
2448 {
2449  uint8 dbTabId = fields[1].GetUInt8();
2450  bool isMoneyTab = (dbTabId == GUILD_BANK_MONEY_LOGS_TAB);
2451  if (dbTabId < _GetPurchasedTabsSize() || isMoneyTab)
2452  {
2453  uint8 tabId = isMoneyTab ? uint8(GUILD_BANK_MAX_TABS) : dbTabId;
2454  LogHolder* pLog = m_bankEventLog[tabId];
2455  if (pLog->CanInsert())
2456  {
2457  uint32 guid = fields[2].GetUInt32();
2458  GuildBankEventLogTypes eventType = GuildBankEventLogTypes(fields[3].GetUInt8());
2459  if (BankEventLogEntry::IsMoneyEvent(eventType))
2460  {
2461  if (!isMoneyTab)
2462  {
2463  TC_LOG_ERROR("guild", "GuildBankEventLog ERROR: MoneyEvent(LogGuid: %u, Guild: " UI64FMTD ") does not belong to money tab (%u), ignoring...", guid, m_id, dbTabId);
2464  return false;
2465  }
2466  }
2467  else if (isMoneyTab)
2468  {
2469  TC_LOG_ERROR("guild", "GuildBankEventLog ERROR: non-money event (LogGuid: %u, Guild: " UI64FMTD ") belongs to money tab, ignoring...", guid, m_id);
2470  return false;
2471  }
2472  pLog->LoadEvent(new BankEventLogEntry(
2473  m_id, // guild id
2474  guid, // guid
2475  fields[8].GetInt64(), // timestamp
2476  dbTabId, // tab id
2477  eventType, // event type
2478  fields[4].GetUInt64(), // player guid
2479  fields[5].GetUInt64(), // item or money
2480  fields[6].GetUInt16(), // itam stack count
2481  fields[7].GetUInt8())); // dest tab id
2482  }
2483  }
2484  return true;
2485 }
LogHolder * m_bankEventLog[GUILD_BANK_MAX_TABS+1]
Definition: Guild.h:864
Definition: Guild.h:50
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:186
Definition: Guild.h:48
uint32 GetUInt32() const
Definition: Field.cpp:105
GuildBankEventLogTypes
Definition: Guild.h:174
#define UI64FMTD
Definition: Define.h:139
uint32_t uint32
Definition: Define.h:152
bool IsMoneyEvent() const
Definition: Guild.h:454
uint8 _GetPurchasedTabsSize() const
Definition: Guild.h:876
ObjectGuid::LowType m_id
Definition: Guild.h:847
uint8 GetUInt8() const
Definition: Field.cpp:33
uint8_t uint8
Definition: Define.h:154
+ Here is the call graph for this function:

◆ LoadBankItemFromDB()

bool Guild::LoadBankItemFromDB ( Field fields)
2512 {
2513  uint8 tabId = fields[52].GetUInt8();
2514  if (tabId >= _GetPurchasedTabsSize())
2515  {
2516  TC_LOG_ERROR("guild", "Invalid tab for item (GUID: %u, id: #%u) in guild bank, skipped.",
2517  fields[0].GetUInt32(), fields[1].GetUInt32());
2518  return false;
2519  }
2520  return m_bankTabs[tabId]->LoadItemFromDB(fields);
2521 }
BankTabs m_bankTabs
Definition: Guild.h:860
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:186
uint8 _GetPurchasedTabsSize() const
Definition: Guild.h:876
uint8 GetUInt8() const
Definition: Field.cpp:33
uint8_t uint8
Definition: Define.h:154
+ Here is the call graph for this function:

◆ LoadBankRightFromDB()

void Guild::LoadBankRightFromDB ( Field fields)
2423 {
2424  // tabId rights slots
2425  GuildBankRightsAndSlots rightsAndSlots(fields[1].GetUInt8(), fields[3].GetInt8(), fields[4].GetInt32());
2426  // rankId
2427  _SetRankBankTabRightsAndSlots(fields[2].GetUInt8(), rightsAndSlots, false);
2428 }
void _SetRankBankTabRightsAndSlots(uint8 rankId, GuildBankRightsAndSlots rightsAndSlots, bool saveToDB=true)
Definition: Guild.cpp:3054
Definition: Guild.h:274
+ Here is the call graph for this function:

◆ LoadBankTabFromDB()

void Guild::LoadBankTabFromDB ( Field fields)
2503 {
2504  uint8 tabId = fields[1].GetUInt8();
2505  if (tabId >= _GetPurchasedTabsSize())
2506  TC_LOG_ERROR("guild", "Invalid tab (tabId: %u) in guild bank, skipped.", tabId);
2507  else
2508  m_bankTabs[tabId]->LoadFromDB(fields);
2509 }
BankTabs m_bankTabs
Definition: Guild.h:860
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:186
uint8 _GetPurchasedTabsSize() const
Definition: Guild.h:876
uint8 GetUInt8() const
Definition: Field.cpp:33
uint8_t uint8
Definition: Define.h:154
+ Here is the call graph for this function:

◆ LoadEventLogFromDB()

bool Guild::LoadEventLogFromDB ( Field fields) const
2431 {
2432  if (m_eventLog->CanInsert())
2433  {
2434  m_eventLog->LoadEvent(new EventLogEntry(
2435  m_id, // guild id
2436  fields[1].GetUInt32(), // guid
2437  fields[6].GetInt64(), // timestamp
2438  GuildEventLogTypes(fields[2].GetUInt8()), // event type
2439  fields[3].GetUInt64(), // player guid 1
2440  fields[4].GetUInt64(), // player guid 2
2441  fields[5].GetUInt8())); // rank
2442  return true;
2443  }
2444  return false;
2445 }
GuildEventLogTypes
Definition: Guild.h:188
LogHolder * m_eventLog
Definition: Guild.h:863
bool CanInsert() const
Definition: Guild.h:526
ObjectGuid::LowType m_id
Definition: Guild.h:847
void LoadEvent(LogEntry *entry)
Definition: Guild.cpp:87
+ Here is the call graph for this function:

◆ LoadFromDB()

bool Guild::LoadFromDB ( Field fields)
2366 {
2367  m_id = fields[0].GetUInt64();
2368  m_name = fields[1].GetString();
2369  m_leaderGuid = ObjectGuid::Create<HighGuid::Player>(fields[2].GetUInt64());
2370 
2371  if (!m_emblemInfo.LoadFromDB(fields))
2372  {
2373  TC_LOG_ERROR("guild", "Guild " UI64FMTD " has invalid emblem colors (Background: %u, Border: %u, Emblem: %u), skipped.",
2375  return false;
2376  }
2377 
2378  m_info = fields[8].GetString();
2379  m_motd = fields[9].GetString();
2380  m_createdDate = time_t(fields[10].GetUInt32());
2381  m_bankMoney = fields[11].GetUInt64();
2382 
2383  uint8 purchasedTabs = uint8(fields[12].GetUInt64());
2384  if (purchasedTabs > GUILD_BANK_MAX_TABS)
2385  purchasedTabs = GUILD_BANK_MAX_TABS;
2386 
2387  m_bankTabs.resize(purchasedTabs);
2388  for (uint8 i = 0; i < purchasedTabs; ++i)
2389  m_bankTabs[i] = new BankTab(m_id, i);
2390 
2392  return true;
2393 }
uint32 GetColor() const
Definition: Guild.h:260
BankTabs m_bankTabs
Definition: Guild.h:860
EmblemInfo m_emblemInfo
Definition: Guild.h:854
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:186
time_t m_createdDate
Definition: Guild.h:852
bool LoadFromDB(Field *fields)
Definition: Guild.cpp:745
Definition: Guild.h:48
ObjectGuid m_leaderGuid
Definition: Guild.h:849
uint64 GetUInt64() const
Definition: Field.cpp:141
std::string m_motd
Definition: Guild.h:850
std::string GetString() const
Definition: Field.cpp:228
#define UI64FMTD
Definition: Define.h:139
std::string m_name
Definition: Guild.h:848
uint32 GetBorderColor() const
Definition: Guild.h:262
void _CreateLogHolders()
Definition: Guild.cpp:2899
ObjectGuid::LowType m_id
Definition: Guild.h:847
uint8_t uint8
Definition: Define.h:154
uint64 m_bankMoney
Definition: Guild.h:856
uint32 GetBackgroundColor() const
Definition: Guild.h:263
std::string m_info
Definition: Guild.h:851
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LoadGuildNewsLogFromDB()

void Guild::LoadGuildNewsLogFromDB ( Field fields) const
2488 {
2489  if (!m_newsLog->CanInsert())
2490  return;
2491 
2492  m_newsLog->LoadEvent(new NewsLogEntry(
2493  m_id, // guild id
2494  fields[1].GetUInt32(), // guid
2495  fields[6].GetInt64(), // timestamp //64 bits?
2496  GuildNews(fields[2].GetUInt8()), // type
2497  ObjectGuid::Create<HighGuid::Player>(fields[3].GetUInt64()), // player guid
2498  fields[4].GetUInt32(), // Flags
2499  fields[5].GetUInt32())); // value
2500 }
GuildNews
Definition: Guild.h:217
bool CanInsert() const
Definition: Guild.h:526
ObjectGuid::LowType m_id
Definition: Guild.h:847
LogHolder * m_newsLog
Definition: Guild.h:865
void LoadEvent(LogEntry *entry)
Definition: Guild.cpp:87
+ Here is the call graph for this function:

◆ LoadMemberFromDB()

bool Guild::LoadMemberFromDB ( Field fields)
2405 {
2406  ObjectGuid::LowType lowguid = fields[1].GetUInt64();
2407  ObjectGuid playerGuid(ObjectGuid::Create<HighGuid::Player>(lowguid));
2408  Member* member = new Member(m_id, playerGuid, fields[2].GetUInt8());
2409  if (!member->LoadFromDB(fields))
2410  {
2411  CharacterDatabaseTransaction trans(nullptr);
2412  Guild::_DeleteMemberFromDB(trans, lowguid);
2413  delete member;
2414  return false;
2415  }
2416 
2417  sCharacterCache->UpdateCharacterGuildId(playerGuid, GetId());
2418  m_members[member->GetGUID()] = member;
2419  return true;
2420 }
uint64 LowType
Definition: ObjectGuid.h:258
#define sCharacterCache
Definition: CharacterCache.h:73
uint64 GetUInt64() const
Definition: Field.cpp:141
ObjectGuid::LowType GetId() const
Definition: Guild.h:725
Members m_members
Definition: Guild.h:859
ObjectGuid::LowType m_id
Definition: Guild.h:847
Definition: ObjectGuid.h:248
static void _DeleteMemberFromDB(CharacterDatabaseTransaction &trans, ObjectGuid::LowType lowguid)
Definition: Guild.cpp:2891
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:72
+ Here is the call graph for this function:

◆ LoadRankFromDB()

void Guild::LoadRankFromDB ( Field fields)
2396 {
2397  RankInfo rankInfo(m_id);
2398 
2399  rankInfo.LoadFromDB(fields);
2400 
2401  m_ranks.push_back(rankInfo);
2402 }
Ranks m_ranks
Definition: Guild.h:858
ObjectGuid::LowType m_id
Definition: Guild.h:847
+ Here is the call graph for this function:

◆ MassInviteToEvent()

void Guild::MassInviteToEvent ( WorldSession session,
uint32  minLevel,
uint32  maxLevel,
uint32  minRank 
)
2652 {
2654 
2655  for (auto itr = m_members.begin(); itr != m_members.end(); ++itr)
2656  {
2657  // not sure if needed, maybe client checks it as well
2658  if (packet.Invites.size() >= CALENDAR_MAX_INVITES)
2659  {
2660  if (Player* player = session->GetPlayer())
2661  sCalendarMgr->SendCalendarCommandResult(player->GetGUID(), CALENDAR_ERROR_INVITES_EXCEEDED);
2662  return;
2663  }
2664 
2665  Member* member = itr->second;
2666  uint32 level = sCharacterCache->GetCharacterLevelByGuid(member->GetGUID());
2667 
2668  if (member->GetGUID() != session->GetPlayer()->GetGUID() && level >= minLevel && level <= maxLevel && member->IsRankNotLower(minRank))
2669  packet.Invites.emplace_back(member->GetGUID(), level);
2670  }
2671 
2672  session->SendPacket(packet.Write());
2673 }
#define sCalendarMgr
Definition: CalendarMgr.h:338
Definition: CalendarMgr.h:109
#define sCharacterCache
Definition: CharacterCache.h:73
ObjectGuid const & GetGUID() const
Definition: Object.h:154
Members m_members
Definition: Guild.h:859
uint32_t uint32
Definition: Define.h:152
Definition: CalendarPackets.h:526
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:208
Player * GetPlayer() const
Definition: WorldSession.h:984
WorldPacket const * Write() override
Definition: CalendarPackets.cpp:460
#define CALENDAR_MAX_INVITES
Definition: CalendarMgr.h:133
std::vector< CalendarEventInitialInviteInfo > Invites
Definition: CalendarPackets.h:533
Definition: Player.h:1081
+ Here is the call graph for this function:

◆ OnPlayerStatusChange()

void Guild::OnPlayerStatusChange ( Player player,
uint32  flag,
bool  state 
)
1295 {
1296  if (Member* member = GetMember(player->GetGUID()))
1297  {
1298  if (state)
1299  member->AddFlag(flag);
1300  else member->RemFlag(flag);
1301  }
1302 }
ObjectGuid const & GetGUID() const
Definition: Object.h:154
Member const * GetMember(ObjectGuid const &guid) const
Definition: Guild.h:880
+ Here is the call graph for this function:

◆ ResetTimes()

void Guild::ResetTimes ( bool  weekly)
3494 {
3495  for (auto itr = m_members.begin(); itr != m_members.end(); ++itr)
3496  {
3497  itr->second->ResetValues(weekly);
3498  if (Player* player = itr->second->FindPlayer())
3499  {
3500  WorldPackets::Guild::GuildMemberDailyReset packet; // tells the client to request bank withdrawal limit
3501  player->GetSession()->SendPacket(packet.Write());
3502  }
3503  }
3504 }
Definition: GuildPackets.h:581
Members m_members
Definition: Guild.h:859
WorldPacket const * Write() override
Definition: GuildPackets.h:586
Definition: Player.h:1081
+ Here is the call graph for this function:

◆ SaveToDB()

void Guild::SaveToDB ( )
1263 {
1264  CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
1265 
1266  m_achievementMgr.SaveToDB(trans);
1267 
1268  CharacterDatabase.CommitTransaction(trans);
1269 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
void SaveToDB(CharacterDatabaseTransaction &trans)
Definition: AchievementMgr.cpp:798
GuildAchievementMgr m_achievementMgr
Definition: Guild.h:866
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:72
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendBankList()

void Guild::SendBankList ( WorldSession session,
uint8  tabId,
bool  fullUpdate 
) const
3396 {
3397  Member const* member = GetMember(session->GetPlayer()->GetGUID());
3398  if (!member) // Shouldn't happen, just in case
3399  return;
3400 
3402 
3403  packet.Money = m_bankMoney;
3404  packet.WithdrawalsRemaining = _GetMemberRemainingSlots(member, tabId);
3405  packet.Tab = int32(tabId);
3406  packet.FullUpdate = fullUpdate;
3407 
3408  // TabInfo
3409  if (fullUpdate)
3410  {
3411  packet.TabInfo.reserve(_GetPurchasedTabsSize());
3412  for (uint8 i = 0; i < _GetPurchasedTabsSize(); ++i)
3413  {
3415  tabInfo.TabIndex = i;
3416  tabInfo.Name = m_bankTabs[i]->GetName();
3417  tabInfo.Icon = m_bankTabs[i]->GetIcon();
3418  packet.TabInfo.push_back(tabInfo);
3419  }
3420  }
3421 
3422  // ItemInfo
3423  uint32 itemCount = 0;
3424  if (fullUpdate && _MemberHasTabRights(session->GetPlayer()->GetGUID(), tabId, GUILD_BANK_RIGHT_VIEW_TAB))
3425  if (BankTab const* tab = GetBankTab(tabId))
3426  for (uint8 slotId = 0; slotId < GUILD_BANK_MAX_SLOTS; ++slotId)
3427  if (tab->GetItem(slotId))
3428  ++itemCount;
3429 
3430  packet.ItemInfo.reserve(itemCount);
3431 
3432  if (fullUpdate && _MemberHasTabRights(session->GetPlayer()->GetGUID(), tabId, GUILD_BANK_RIGHT_VIEW_TAB))
3433  {
3434  if (BankTab const* tab = GetBankTab(tabId))
3435  {
3436  for (uint8 slotId = 0; slotId < GUILD_BANK_MAX_SLOTS; ++slotId)
3437  {
3438  if (Item* tabItem = tab->GetItem(slotId))
3439  {
3441 
3442  itemInfo.Slot = int32(slotId);
3443  itemInfo.Item.ItemID = tabItem->GetEntry();
3444  itemInfo.Count = int32(tabItem->GetCount());
3445  itemInfo.Charges = int32(abs(tabItem->GetSpellCharges()));
3446  itemInfo.EnchantmentID = int32(tabItem->GetEnchantmentId(PERM_ENCHANTMENT_SLOT));
3447  itemInfo.OnUseEnchantmentID = int32(tabItem->GetEnchantmentId(USE_ENCHANTMENT_SLOT));
3448  itemInfo.Flags = tabItem->m_itemData->DynamicFlags;
3449 
3450  uint8 i = 0;
3451  for (UF::SocketedGem const& gemData : tabItem->m_itemData->Gems)
3452  {
3453  if (gemData.ItemID)
3454  {
3456  gem.Slot = i;
3457  gem.Item.Initialize(&gemData);
3458  itemInfo.SocketEnchant.push_back(gem);
3459  }
3460  ++i;
3461  }
3462 
3463  itemInfo.Locked = false;
3464 
3465  packet.ItemInfo.push_back(itemInfo);
3466  }
3467  }
3468  }
3469  }
3470 
3471  session->SendPacket(packet.Write());
3472 }
WorldPackets::Item::ItemInstance Item
Definition: GuildPackets.h:800
ItemInstance Item
Definition: ItemPacketsCommon.h:97
int32 Charges
Definition: GuildPackets.h:804
Definition: GuildPackets.h:811
Definition: GuildPackets.h:818
BankTabs m_bankTabs
Definition: Guild.h:860
int32 OnUseEnchantmentID
Definition: GuildPackets.h:805
uint8 Slot
Definition: ItemPacketsCommon.h:96
int32 Count
Definition: GuildPackets.h:802
Definition: ItemPacketsCommon.h:94
BankTab * GetBankTab(uint8 tabId)
Definition: Guild.h:877
int32 Flags
Definition: GuildPackets.h:806
int32 Slot
Definition: GuildPackets.h:801
bool Locked
Definition: GuildPackets.h:807
std::string Name
Definition: GuildPackets.h:814
std::vector< Item::ItemGemData > SocketEnchant
Definition: GuildPackets.h:808
UpdateField< int32, 0, 1 > ItemID
Definition: UpdateFields.h:106
Definition: UpdateFields.h:104
ObjectGuid const & GetGUID() const
Definition: Object.h:154
int32 Tab
Definition: GuildPackets.h:828
Definition: GuildPackets.h:798
Definition: Item.h:169
int32_t int32
Definition: Define.h:148
int32 EnchantmentID
Definition: GuildPackets.h:803
uint32_t uint32
Definition: Define.h:152
uint64 Money
Definition: GuildPackets.h:829
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:208
Definition: ItemDefines.h:165
int32 _GetMemberRemainingSlots(Member const *member, uint8 tabId) const
Definition: Guild.cpp:3099
int32 TabIndex
Definition: GuildPackets.h:813
Player * GetPlayer() const
Definition: WorldSession.h:984
uint8 _GetPurchasedTabsSize() const
Definition: Guild.h:876
std::vector< GuildBankItemInfo > ItemInfo
Definition: GuildPackets.h:825
void Initialize(::Item const *item)
Definition: ItemPacketsCommon.cpp:50
Definition: Guild.h:166
uint8_t uint8
Definition: Define.h:154
Definition: ItemDefines.h:172
std::vector< GuildBankTabInfo > TabInfo
Definition: GuildPackets.h:826
Member const * GetMember(ObjectGuid const &guid) const
Definition: Guild.h:880
uint64 m_bankMoney
Definition: Guild.h:856
WorldPacket const * Write() override
Definition: GuildPackets.cpp:611
std::string Icon
Definition: GuildPackets.h:815
Definition: Guild.h:49
bool _MemberHasTabRights(ObjectGuid guid, uint8 tabId, int32 rights) const
Definition: Guild.cpp:3140
uint32 ItemID
Definition: ItemPacketsCommon.h:77
bool FullUpdate
Definition: GuildPackets.h:830
int32 WithdrawalsRemaining
Definition: GuildPackets.h:827
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendBankLog()

void Guild::SendBankLog ( WorldSession session,
uint8  tabId 
) const
2145 {
2146  // GUILD_BANK_MAX_TABS send by client for money log
2147  if (tabId < _GetPurchasedTabsSize() || tabId == GUILD_BANK_MAX_TABS)
2148  {
2149  GuildLog* logs = m_bankEventLog[tabId]->GetGuildLog();
2150 
2151  if (!logs)
2152  return;
2153 
2155  packet.Tab = int32(tabId);
2156 
2157  //if (tabId == GUILD_BANK_MAX_TABS && hasCashFlow)
2158  // packet.WeeklyBonusMoney.Set(uint64(weeklyBonusMoney));
2159 
2160  packet.Entry.reserve(m_bankEventLog[tabId]->GetSize());
2161  for (GuildLog::const_iterator itr = logs->begin(); itr != logs->end(); ++itr)
2162  {
2163  BankEventLogEntry* bankEventLog = static_cast<BankEventLogEntry*>(*itr);
2164  bankEventLog->WritePacket(packet);
2165  }
2166 
2167  session->SendPacket(packet.Write());
2168 
2169  TC_LOG_DEBUG("guild", "SMSG_GUILD_BANK_LOG_QUERY_RESULT [%s] TabId: %u", session->GetPlayerInfo().c_str(), tabId);
2170  }
2171 }
LogHolder * m_bankEventLog[GUILD_BANK_MAX_TABS+1]
Definition: Guild.h:864
GuildLog * GetGuildLog()
Definition: Guild.h:532
Definition: Guild.h:48
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:192
int32_t int32
Definition: Define.h:148
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:208
WorldPacket const * Write() override
Definition: GuildPackets.cpp:804
uint8 _GetPurchasedTabsSize() const
Definition: Guild.h:876
std::vector< GuildBankLogEntry > Entry
Definition: GuildPackets.h:1032
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
int32 Tab
Definition: GuildPackets.h:1031
Definition: GuildPackets.h:1024
std::list< LogEntry * > GuildLog
Definition: Guild.h:516
+ Here is the call graph for this function:

◆ SendBankTabText()

void Guild::SendBankTabText ( WorldSession session,
uint8  tabId 
) const
2174 {
2175  if (BankTab const* tab = GetBankTab(tabId))
2176  tab->SendText(this, session);
2177 }
BankTab * GetBankTab(uint8 tabId)
Definition: Guild.h:877
+ Here is the call graph for this function:

◆ SendCommandResult()

void Guild::SendCommandResult ( WorldSession session,
GuildCommandType  type,
GuildCommandError  errCode,
std::string const &  param = "" 
)
static
58 {
60  resultPacket.Command = type;
61  resultPacket.Result = errCode;
62  resultPacket.Name = param;
63  session->SendPacket(resultPacket.Write());
64 
65  TC_LOG_DEBUG("guild", "SMSG_GUILD_COMMAND_RESULT [%s]: Type: %u, code: %u, param: %s"
66  , session->GetPlayerInfo().c_str(), type, errCode, param.c_str());
67 }
int32 Command
Definition: GuildPackets.h:171
int32 Result
Definition: GuildPackets.h:170
std::string Name
Definition: GuildPackets.h:169
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:192
Definition: GuildPackets.h:162
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:208
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
WorldPacket const * Write() override
Definition: GuildPackets.cpp:100
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendEventAwayChanged()

void Guild::SendEventAwayChanged ( ObjectGuid const &  memberGuid,
bool  afk,
bool  dnd 
)
2265 {
2266  Member* member = GetMember(memberGuid);
2267  if (!member)
2268  return;
2269 
2270  if (afk)
2271  member->AddFlag(GUILDMEMBER_STATUS_AFK);
2272  else
2273  member->RemFlag(GUILDMEMBER_STATUS_AFK);
2274 
2275  if (dnd)
2276  member->AddFlag(GUILDMEMBER_STATUS_DND);
2277  else
2278  member->RemFlag(GUILDMEMBER_STATUS_DND);
2279 
2281  statusChange.Guid = memberGuid;
2282  statusChange.AFK = afk;
2283  statusChange.DND = dnd;
2284  BroadcastPacket(statusChange.Write());
2285 }
Definition: Guild.h:213
WorldPacket const * Write() override
Definition: GuildPackets.cpp:199
bool DND
Definition: GuildPackets.h:243
void BroadcastPacket(WorldPacket const *packet) const
Definition: Guild.cpp:2636
ObjectGuid Guid
Definition: GuildPackets.h:241
Definition: GuildPackets.h:234
Definition: Guild.h:212
Member const * GetMember(ObjectGuid const &guid) const
Definition: Guild.h:880
bool AFK
Definition: GuildPackets.h:242
+ Here is the call graph for this function:

◆ SendEventBankMoneyChanged()

void Guild::SendEventBankMoneyChanged ( ) const
2288 {
2290  eventPacket.Money = GetBankMoney();
2291  BroadcastPacket(eventPacket.Write());
2292 }
uint64 GetBankMoney() const
Definition: Guild.h:732
WorldPacket const * Write() override
Definition: GuildPackets.cpp:254
void BroadcastPacket(WorldPacket const *packet) const
Definition: Guild.cpp:2636
uint64 Money
Definition: GuildPackets.h:307
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendEventLog()

void Guild::SendEventLog ( WorldSession session) const
2103 {
2104  GuildLog* logs = m_eventLog->GetGuildLog();
2105 
2106  if (!logs)
2107  return;
2108 
2110  packet.Entry.reserve(m_eventLog->GetSize());
2111 
2112  for (GuildLog::const_iterator itr = logs->begin(); itr != logs->end(); ++itr)
2113  {
2114  EventLogEntry* eventLog = static_cast<EventLogEntry*>(*itr);
2115  eventLog->WritePacket(packet);
2116  }
2117 
2118  session->SendPacket(packet.Write());
2119 
2120  TC_LOG_DEBUG("guild", "SMSG_GUILD_EVENT_LOG_QUERY_RESULTS [%s]", session->GetPlayerInfo().c_str());
2121 }
LogHolder * m_eventLog
Definition: Guild.h:863
uint8 GetSize() const
Definition: Guild.h:524
GuildLog * GetGuildLog()
Definition: Guild.h:532
WorldPacket const * Write() override
Definition: GuildPackets.cpp:261
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:192
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:208
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
std::vector< GuildEventEntry > Entry
Definition: GuildPackets.h:342
std::list< LogEntry * > GuildLog
Definition: Guild.h:516
+ Here is the call graph for this function:

◆ SendEventMOTD()

void Guild::SendEventMOTD ( WorldSession session,
bool  broadcast = false 
) const
2295 {
2297  eventPacket.MotdText = GetMOTD();
2298 
2299  if (broadcast)
2300  BroadcastPacket(eventPacket.Write());
2301  else
2302  {
2303  session->SendPacket(eventPacket.Write());
2304  TC_LOG_DEBUG("guild", "SMSG_GUILD_EVENT_MOTD [%s] ", session->GetPlayerInfo().c_str());
2305  }
2306 }
WorldPacket const * Write() override
Definition: GuildPackets.cpp:224
void BroadcastPacket(WorldPacket const *packet) const
Definition: Guild.cpp:2636
Definition: GuildPackets.h:260
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:192
std::string MotdText
Definition: GuildPackets.h:267
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:208
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
std::string const & GetMOTD() const
Definition: Guild.h:729
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendEventNewLeader()

void Guild::SendEventNewLeader ( Member newLeader,
Member oldLeader,
bool  isSelfPromoted = false 
) const
2309 {
2311  eventPacket.SelfPromoted = isSelfPromoted;
2312  if (newLeader)
2313  {
2314  eventPacket.NewLeaderGUID = newLeader->GetGUID();
2315  eventPacket.NewLeaderName = newLeader->GetName();
2317  }
2318 
2319  if (oldLeader)
2320  {
2321  eventPacket.OldLeaderGUID = oldLeader->GetGUID();
2322  eventPacket.OldLeaderName = oldLeader->GetName();
2324  }
2325 
2326  BroadcastPacket(eventPacket.Write());
2327 }
uint32 OldLeaderVirtualRealmAddress
Definition: GuildPackets.h:373
uint32 NewLeaderVirtualRealmAddress
Definition: GuildPackets.h:370
WorldPacket const * Write() override
Definition: GuildPackets.cpp:338
std::string OldLeaderName
Definition: GuildPackets.h:372
void BroadcastPacket(WorldPacket const *packet) const
Definition: Guild.cpp:2636
std::string NewLeaderName
Definition: GuildPackets.h:369
ObjectGuid OldLeaderGUID
Definition: GuildPackets.h:371
uint32 GetVirtualRealmAddress()
Definition: World.cpp:3737
Definition: GuildPackets.h:361
ObjectGuid NewLeaderGUID
Definition: GuildPackets.h:368
bool SelfPromoted
Definition: GuildPackets.h:374
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendEventPlayerLeft()

void Guild::SendEventPlayerLeft ( Member leaver,
Member remover = nullptr,
bool  isRemoved = false 
) const
2330 {
2332  eventPacket.Removed = isRemoved;
2333  eventPacket.LeaverGUID = leaver->GetGUID();
2334  eventPacket.LeaverName = leaver->GetName();
2336 
2337  if (isRemoved && remover != nullptr)
2338  {
2339  eventPacket.RemoverGUID = remover->GetGUID();
2340  eventPacket.RemoverName = remover->GetName();
2342  }
2343 
2344  BroadcastPacket(eventPacket.Write());
2345 }
uint32 RemoverVirtualRealmAddress
Definition: GuildPackets.h:357
ObjectGuid LeaverGUID
Definition: GuildPackets.h:352
void BroadcastPacket(WorldPacket const *packet) const
Definition: Guild.cpp:2636
bool Removed
Definition: GuildPackets.h:358
uint32 LeaverVirtualRealmAddress
Definition: GuildPackets.h:354
std::string LeaverName
Definition: GuildPackets.h:353
Definition: GuildPackets.h:345
uint32 GetVirtualRealmAddress()
Definition: World.cpp:3737
std::string RemoverName
Definition: GuildPackets.h:356
ObjectGuid RemoverGUID
Definition: GuildPackets.h:355
WorldPacket const * Write() override
Definition: GuildPackets.cpp:279
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendEventPresenceChanged()

void Guild::SendEventPresenceChanged ( WorldSession session,
bool  loggedOn,
bool  broadcast = false 
) const
2348 {
2349  Player* player = session->GetPlayer();
2350 
2352  eventPacket.Guid = player->GetGUID();
2353  eventPacket.Name = player->GetName();
2355  eventPacket.LoggedOn = loggedOn;
2356  eventPacket.Mobile = false;
2357 
2358  if (broadcast)
2359  BroadcastPacket(eventPacket.Write());
2360  else
2361  session->SendPacket(eventPacket.Write());
2362 }
void BroadcastPacket(WorldPacket const *packet) const
Definition: Guild.cpp:2636
bool LoggedOn
Definition: GuildPackets.h:257
ObjectGuid const & GetGUID() const
Definition: Object.h:154
std::string const & GetName() const
Definition: Object.h:467
uint32 VirtualRealmAddress
Definition: GuildPackets.h:254
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:208
WorldPacket const * Write() override
Definition: GuildPackets.cpp:209
Player * GetPlayer() const
Definition: WorldSession.h:984
std::string Name
Definition: GuildPackets.h:255
bool Mobile
Definition: GuildPackets.h:256
uint32 GetVirtualRealmAddress()
Definition: World.cpp:3737
Definition: GuildPackets.h:246
Definition: Player.h:1081
ObjectGuid Guid
Definition: GuildPackets.h:253
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendGuildRankInfo()

void Guild::SendGuildRankInfo ( WorldSession session) const
1401 {
1403 
1404  ranks.Ranks.reserve(_GetRanksSize());
1405 
1406  for (uint8 i = 0; i < _GetRanksSize(); i++)
1407  {
1408  RankInfo const* rankInfo = GetRankInfo(i);
1409  if (!rankInfo)
1410  continue;
1411 
1413 
1414  rankData.RankID = rankInfo->GetId();
1415  rankData.RankOrder = uint32(i);
1416  rankData.Flags = rankInfo->GetRights();
1417  rankData.WithdrawGoldLimit = (rankInfo->GetId() == GR_GUILDMASTER ? (-1) : int32(rankInfo->GetBankMoneyPerDay() / GOLD));
1418  rankData.RankName = rankInfo->GetName();
1419 
1420  for (uint8 j = 0; j < GUILD_BANK_MAX_TABS; ++j)
1421  {
1422  rankData.TabFlags[j] = uint32(rankInfo->GetBankTabRights(j));
1423  rankData.TabWithdrawItemLimit[j] = uint32(rankInfo->GetBankTabSlotsPerDay(j));
1424  }
1425