TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 constGetName () const
 
std::string constGetMOTD () const
 
std::string constGetInfo () const
 
time_t GetCreatedDate () const
 
uint64 GetBankMoney () const
 
bool SetName (std::string const &name)
 
void HandleRoster (WorldSession *session)
 
void SendQueryResponse (WorldSession *session)
 
void HandleSetAchievementTracking (WorldSession *session, std::set< uint32 > const &achievementIds)
 
void HandleSetMOTD (WorldSession *session, std::string const &motd)
 
void HandleSetInfo (WorldSession *session, std::string const &info)
 
void HandleSetEmblem (WorldSession *session, const EmblemInfo &emblemInfo)
 
void HandleSetNewGuildMaster (WorldSession *session, std::string const &name)
 
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)
 
void HandleNewsSetSticky (WorldSession *session, uint32 newsId, bool sticky)
 
void HandleGuildRequestChallengeUpdate (WorldSession *session)
 
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)
 
void SendEventBankMoneyChanged ()
 
void SendEventMOTD (WorldSession *session, bool broadcast=false)
 
void SendEventNewLeader (Member *newLeader, Member *oldLeader, bool isSelfPromoted=false)
 
void SendEventPlayerLeft (Member *leaver, Member *remover=nullptr, bool isRemoved=false)
 
void SendEventPresenceChanged (WorldSession *session, bool loggedOn, bool broadcast=false)
 
bool LoadFromDB (Field *fields)
 
void LoadGuildNewsLogFromDB (Field *fields)
 
void LoadRankFromDB (Field *fields)
 
bool LoadMemberFromDB (Field *fields)
 
bool LoadEventLogFromDB (Field *fields)
 
void LoadBankRightFromDB (Field *fields)
 
void LoadBankTabFromDB (Field *fields)
 
bool LoadBankEventLogFromDB (Field *fields)
 
bool LoadBankItemFromDB (Field *fields)
 
bool Validate ()
 
void BroadcastToGuild (WorldSession *session, bool officerOnly, std::string const &msg, uint32 language=LANG_UNIVERSAL) const
 
void BroadcastAddonToGuild (WorldSession *session, bool officerOnly, std::string const &msg, std::string const &prefix) 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=NULL)
 
bool AddMember (ObjectGuid guid, uint8 rankId=GUILD_RANK_NONE)
 
void DeleteMember (ObjectGuid guid, bool isDisbanding=false, bool isKicked=false, bool canDeleteGuild=false)
 
bool ChangeMemberRank (ObjectGuid guid, uint8 newRank)
 
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)
 
AchievementMgr< Guild > & GetAchievementMgr ()
 
AchievementMgr< Guild > constGetAchievementMgr () const
 
uint8 GetLevel () const
 
void AddGuildNews (uint8 type, ObjectGuid guid, uint32 flags, uint32 value)
 
EmblemInfo constGetEmblemInfo () const
 
void ResetTimes (bool weekly)
 
bool HasAchieved (uint32 achievementId) const
 
void UpdateAchievementCriteria (AchievementCriteriaTypes type, uint64 miscValue1, uint64 miscValue2, uint64 miscValue3, Unit *unit, 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
 
AchievementMgr< Guildm_achievementMgr
 
uint8 _level
 

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
 
const RankInfoGetRankInfo (uint8 rankId) const
 
RankInfoGetRankInfo (uint8 rankId)
 
bool _HasRankRight (Player const *player, uint32 right) const
 
uint8 _GetLowestRankId () const
 
uint8 _GetPurchasedTabsSize () const
 
BankTabGetBankTab (uint8 tabId)
 
const BankTabGetBankTab (uint8 tabId) const
 
const MemberGetMember (ObjectGuid guid) const
 
MemberGetMember (ObjectGuid guid)
 
MemberGetMember (std::string const &name)
 
void _DeleteMemberFromDB (ObjectGuid::LowType lowguid) const
 
void _CreateLogHolders ()
 
void _CreateNewBankTab ()
 
void _CreateDefaultGuildRanks (LocaleConstant loc)
 
bool _CreateRank (std::string const &name, uint32 rights)
 
void _UpdateAccountsNumber ()
 
bool _IsLeader (Player *player) const
 
void _DeleteBankItems (SQLTransaction &trans, bool removeItemsFromDB=false)
 
bool _ModifyBankMoney (SQLTransaction &trans, uint64 amount, bool add)
 
void _SetLeaderGUID (Member *pLeader)
 
void _SetRankBankMoneyPerDay (uint8 rankId, uint32 moneyPerDay)
 
void _SetRankBankTabRightsAndSlots (uint8 rankId, GuildBankRightsAndSlots rightsAndSlots, bool saveToDB=true)
 
int8 _GetRankBankTabRights (uint8 rankId, uint8 tabId) const
 
uint32 _GetRankRights (uint8 rankId) const
 
int32 _GetRankBankMoneyPerDay (uint8 rankId) const
 
int32 _GetRankBankTabSlotsPerDay (uint8 rankId, uint8 tabId) const
 
std::string _GetRankName (uint8 rankId) const
 
int32 _GetMemberRemainingSlots (Member const *member, uint8 tabId) const
 
int32 _GetMemberRemainingMoney (Member const *member) const
 
void _UpdateMemberWithdrawSlots (SQLTransaction &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 (SQLTransaction &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 (SQLTransaction &trans, uint8 tabId, uint8 slotId)
 
void _MoveItems (MoveItemData *pSrc, MoveItemData *pDest, uint32 splitedAmount)
 
bool _DoItemsMove (MoveItemData *pSrc, MoveItemData *pDest, bool sendError, uint32 splitedAmount=0)
 
void _SendBankContentUpdate (MoveItemData *pSrc, MoveItemData *pDest) const
 
void _SendBankContentUpdate (uint8 tabId, SlotIds slots) const
 
void SendGuildRanksUpdate (ObjectGuid setterGuid, ObjectGuid targetGuid, uint32 rank)
 

Member Typedef Documentation

typedef std::vector<BankTab*> Guild::BankTabs
private
typedef std::list<LogEntry*> Guild::GuildLog
private
typedef std::unordered_map<ObjectGuid, Member*> Guild::Members
private
typedef std::vector<RankInfo> Guild::Ranks
private

Constructor & Destructor Documentation

Guild::Guild ( )
1039  :
1040  m_id(UI64LIT(0)),
1041  m_leaderGuid(),
1042  m_createdDate(0),
1043  m_accountsNumber(0),
1044  m_bankMoney(0),
1045  m_eventLog(NULL),
1046  m_newsLog(NULL),
1047  m_achievementMgr(this),
1048  _level(1)
1049 {
1050  memset(&m_bankEventLog, 0, (GUILD_BANK_MAX_TABS + 1) * sizeof(LogHolder*));
1051 }
AchievementMgr< Guild > m_achievementMgr
Definition: Guild.h:902
LogHolder * m_eventLog
Definition: Guild.h:899
LogHolder * m_bankEventLog[GUILD_BANK_MAX_TABS+1]
Definition: Guild.h:900
uint32 m_accountsNumber
Definition: Guild.h:891
#define UI64LIT(N)
Definition: Define.h:138
arena_t NULL
Definition: jemalloc_internal.h:624
time_t m_createdDate
Definition: Guild.h:888
Definition: Guild.h:44
ObjectGuid m_leaderGuid
Definition: Guild.h:885
ObjectGuid::LowType m_id
Definition: Guild.h:883
uint64 m_bankMoney
Definition: Guild.h:892
uint8 _level
Definition: Guild.h:904
LogHolder * m_newsLog
Definition: Guild.h:901
Guild::~Guild ( )
1054 {
1055  SQLTransaction temp(NULL);
1056  _DeleteBankItems(temp);
1057 
1058  // Cleanup
1059  delete m_eventLog;
1060  m_eventLog = NULL;
1061  delete m_newsLog;
1062  m_newsLog = NULL;
1063 
1064  for (uint8 tabId = 0; tabId <= GUILD_BANK_MAX_TABS; ++tabId)
1065  {
1066  delete m_bankEventLog[tabId];
1067  m_bankEventLog[tabId] = NULL;
1068  }
1069 
1070  for (Members::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
1071  {
1072  delete itr->second;
1073  itr->second = NULL;
1074  }
1075 }
LogHolder * m_eventLog
Definition: Guild.h:899
LogHolder * m_bankEventLog[GUILD_BANK_MAX_TABS+1]
Definition: Guild.h:900
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Guild.h:44
Members m_members
Definition: Guild.h:895
uint8_t uint8
Definition: Define.h:152
LogHolder * m_newsLog
Definition: Guild.h:901
void _DeleteBankItems(SQLTransaction &trans, bool removeItemsFromDB=false)
Definition: Guild.cpp:2859
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

Member Function Documentation

void Guild::_CreateDefaultGuildRanks ( LocaleConstant  loc)
private
2801 {
2803  stmt->setUInt64(0, m_id);
2804  CharacterDatabase.Execute(stmt);
2805 
2807  stmt->setUInt64(0, m_id);
2808  CharacterDatabase.Execute(stmt);
2809 
2810  _CreateRank(sObjectMgr->GetTrinityString(LANG_GUILD_MASTER, loc), GR_RIGHT_ALL);
2811  _CreateRank(sObjectMgr->GetTrinityString(LANG_GUILD_OFFICER, loc), GR_RIGHT_ALL);
2815 }
Definition: Guild.h:99
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Definition: CharacterDatabase.h:175
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: PreparedStatement.h:74
Definition: Language.h:779
Definition: Guild.h:78
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Definition: Language.h:780
ObjectGuid::LowType m_id
Definition: Guild.h:883
bool _CreateRank(std::string const &name, uint32 rights)
Definition: Guild.cpp:2817
Definition: Language.h:781
Definition: Language.h:778
Definition: Guild.h:79
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: Language.h:782
Definition: CharacterDatabase.h:165

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Guild::_CreateLogHolders ( )
private
2769 {
2770  m_eventLog = new LogHolder(sWorld->getIntConfig(CONFIG_GUILD_EVENT_LOG_COUNT));
2771  m_newsLog = new LogHolder(sWorld->getIntConfig(CONFIG_GUILD_NEWS_LOG_COUNT));
2772  for (uint8 tabId = 0; tabId <= GUILD_BANK_MAX_TABS; ++tabId)
2773  m_bankEventLog[tabId] = new LogHolder(sWorld->getIntConfig(CONFIG_GUILD_BANK_EVENT_LOG_COUNT));
2774 }
Definition: World.h:327
LogHolder * m_eventLog
Definition: Guild.h:899
LogHolder * m_bankEventLog[GUILD_BANK_MAX_TABS+1]
Definition: Guild.h:900
#define sWorld
Definition: World.h:887
Definition: World.h:326
Definition: Guild.h:44
Definition: World.h:328
uint8_t uint8
Definition: Define.h:152
LogHolder * m_newsLog
Definition: Guild.h:901

+ Here is the caller graph for this function:

void Guild::_CreateNewBankTab ( )
private
2777 {
2778  uint8 tabId = _GetPurchasedTabsSize(); // Next free id
2779  m_bankTabs.push_back(new BankTab(m_id, tabId));
2780 
2782 
2784  stmt->setUInt64(0, m_id);
2785  stmt->setUInt8 (1, tabId);
2786  trans->Append(stmt);
2787 
2789  stmt->setUInt64(0, m_id);
2790  stmt->setUInt8 (1, tabId);
2791  trans->Append(stmt);
2792 
2793  ++tabId;
2794  for (Ranks::iterator itr = m_ranks.begin(); itr != m_ranks.end(); ++itr)
2795  (*itr).CreateMissingTabsIfNeeded(tabId, trans, false);
2796 
2798 }
BankTabs m_bankTabs
Definition: Guild.h:896
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
Definition: PreparedStatement.h:74
Definition: CharacterDatabase.h:167
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
uint8 _GetPurchasedTabsSize() const
Definition: Guild.h:920
Definition: CharacterDatabase.h:168
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Ranks m_ranks
Definition: Guild.h:894
ObjectGuid::LowType m_id
Definition: Guild.h:883
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
uint8_t uint8
Definition: Define.h:152
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Guild::_CreateRank ( std::string const name,
uint32  rights 
)
private
2818 {
2819  uint8 newRankId = _GetRanksSize();
2820  if (newRankId >= GUILD_RANKS_MAX_COUNT)
2821  return false;
2822 
2823  // Ranks represent sequence 0, 1, 2, ... where 0 means guildmaster
2824  RankInfo info(m_id, newRankId, name, rights, 0);
2825  m_ranks.push_back(info);
2826 
2828  info.CreateMissingTabsIfNeeded(_GetPurchasedTabsSize(), trans);
2829  info.SaveToDB(trans);
2831 
2832  return true;
2833 }
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
uint8 _GetPurchasedTabsSize() const
Definition: Guild.h:920
uint8 _GetRanksSize() const
Definition: Guild.h:907
Ranks m_ranks
Definition: Guild.h:894
ObjectGuid::LowType m_id
Definition: Guild.h:883
uint8_t uint8
Definition: Define.h:152
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: Guild.h:48
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Guild::_DeleteBankItems ( SQLTransaction trans,
bool  removeItemsFromDB = false 
)
private
2860 {
2861  for (uint8 tabId = 0; tabId < _GetPurchasedTabsSize(); ++tabId)
2862  {
2863  m_bankTabs[tabId]->Delete(trans, removeItemsFromDB);
2864  delete m_bankTabs[tabId];
2865  m_bankTabs[tabId] = NULL;
2866  }
2867  m_bankTabs.clear();
2868 }
BankTabs m_bankTabs
Definition: Guild.h:896
arena_t NULL
Definition: jemalloc_internal.h:624
uint8 _GetPurchasedTabsSize() const
Definition: Guild.h:920
uint8_t uint8
Definition: Define.h:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Guild::_DeleteMemberFromDB ( ObjectGuid::LowType  lowguid) const
inlineprivate
946  {
948  stmt->setUInt64(0, lowguid);
950  }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Definition: CharacterDatabase.h:162
Definition: PreparedStatement.h:74
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Guild::_DoItemsMove ( MoveItemData pSrc,
MoveItemData pDest,
bool  sendError,
uint32  splitedAmount = 0 
)
private
3119 {
3120  Item* pDestItem = pDest->GetItem();
3121  bool swap = (pDestItem != NULL);
3122 
3123  Item* pSrcItem = pSrc->GetItem(splitedAmount != 0);
3124  // 1. Can store source item in destination
3125  if (!pDest->CanStore(pSrcItem, swap, sendError))
3126  return false;
3127 
3128  // 2. Can store destination item in source
3129  if (swap)
3130  if (!pSrc->CanStore(pDestItem, true, true))
3131  return false;
3132 
3133  // GM LOG (@todo move to scripts)
3134  pDest->LogAction(pSrc);
3135  if (swap)
3136  pSrc->LogAction(pDest);
3137 
3139  // 3. Log bank events
3140  pDest->LogBankEvent(trans, pSrc, pSrcItem->GetCount());
3141  if (swap)
3142  pSrc->LogBankEvent(trans, pDest, pDestItem->GetCount());
3143 
3144  // 4. Remove item from source
3145  pSrc->RemoveItem(trans, pDest, splitedAmount);
3146 
3147  // 5. Remove item from destination
3148  if (swap)
3149  pDest->RemoveItem(trans, pSrc);
3150 
3151  // 6. Store item in destination
3152  pDest->StoreItem(trans, pSrcItem);
3153 
3154  // 7. Store item in source
3155  if (swap)
3156  pSrc->StoreItem(trans, pDestItem);
3157 
3159  return true;
3160 }
uint32 GetCount() const
Definition: Item.h:322
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
arena_t NULL
Definition: jemalloc_internal.h:624
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
Definition: Item.h:259
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Item * Guild::_GetItem ( uint8  tabId,
uint8  slotId 
) const
inlineprivate
3045 {
3046  if (const BankTab* tab = GetBankTab(tabId))
3047  return tab->GetItem(slotId);
3048  return NULL;
3049 }
arena_t NULL
Definition: jemalloc_internal.h:624
BankTab * GetBankTab(uint8 tabId)
Definition: Guild.h:921

+ Here is the call graph for this function:

uint8 Guild::_GetLowestRankId ( ) const
inlineprivate
918 { return uint8(m_ranks.size() - 1); }
Ranks m_ranks
Definition: Guild.h:894
uint8_t uint8
Definition: g3dmath.h:164

+ Here is the caller graph for this function:

int32 Guild::_GetMemberRemainingMoney ( Member const member) const
inlineprivate
2972 {
2973  if (member)
2974  {
2975  uint8 rankId = member->GetRankId();
2976  if (rankId == GR_GUILDMASTER)
2977  return static_cast<int32>(GUILD_WITHDRAW_MONEY_UNLIMITED);
2978 
2980  {
2981  int32 remaining = _GetRankBankMoneyPerDay(rankId) - member->GetBankWithdrawValue(GUILD_BANK_MAX_TABS);
2982  if (remaining > 0)
2983  return remaining;
2984  }
2985  }
2986  return 0;
2987 }
Definition: Guild.h:66
Definition: Guild.h:96
Definition: Guild.h:44
uint32 _GetRankRights(uint8 rankId) const
Definition: Guild.cpp:2925
int32_t int32
Definition: Define.h:146
Definition: Guild.h:97
int32 _GetRankBankMoneyPerDay(uint8 rankId) const
Definition: Guild.cpp:2932
uint8_t uint8
Definition: Define.h:152
Definition: Guild.h:50

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32 Guild::_GetMemberRemainingSlots ( Member const member,
uint8  tabId 
) const
inlineprivate
2955 {
2956  if (member)
2957  {
2958  uint8 rankId = member->GetRankId();
2959  if (rankId == GR_GUILDMASTER)
2960  return static_cast<int32>(GUILD_WITHDRAW_SLOT_UNLIMITED);
2961  if ((_GetRankBankTabRights(rankId, tabId) & GUILD_BANK_RIGHT_VIEW_TAB) != 0)
2962  {
2963  int32 remaining = _GetRankBankTabSlotsPerDay(rankId, tabId) - member->GetBankWithdrawValue(tabId);
2964  if (remaining > 0)
2965  return remaining;
2966  }
2967  }
2968  return 0;
2969 }
Definition: Guild.h:66
int32 _GetRankBankTabSlotsPerDay(uint8 rankId, uint8 tabId) const
Definition: Guild.cpp:2939
int8 _GetRankBankTabRights(uint8 rankId, uint8 tabId) const
Definition: Guild.cpp:2947
int32_t int32
Definition: Define.h:146
Definition: Guild.h:181
uint8_t uint8
Definition: Define.h:152
Definition: Guild.h:51

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint8 Guild::_GetPurchasedTabsSize ( ) const
inlineprivate
920 { return uint8(m_bankTabs.size()); }
BankTabs m_bankTabs
Definition: Guild.h:896
uint8_t uint8
Definition: g3dmath.h:164

+ Here is the caller graph for this function:

int32 Guild::_GetRankBankMoneyPerDay ( uint8  rankId) const
inlineprivate
2933 {
2934  if (const RankInfo* rankInfo = GetRankInfo(rankId))
2935  return rankInfo->GetBankMoneyPerDay();
2936  return 0;
2937 }
const RankInfo * GetRankInfo(uint8 rankId) const
Definition: Guild.h:908

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int8 Guild::_GetRankBankTabRights ( uint8  rankId,
uint8  tabId 
) const
inlineprivate
2948 {
2949  if (const RankInfo* rankInfo = GetRankInfo(rankId))
2950  return rankInfo->GetBankTabRights(tabId);
2951  return 0;
2952 }
const RankInfo * GetRankInfo(uint8 rankId) const
Definition: Guild.h:908

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32 Guild::_GetRankBankTabSlotsPerDay ( uint8  rankId,
uint8  tabId 
) const
inlineprivate
2940 {
2941  if (tabId < _GetPurchasedTabsSize())
2942  if (const RankInfo* rankInfo = GetRankInfo(rankId))
2943  return rankInfo->GetBankTabSlotsPerDay(tabId);
2944  return 0;
2945 }
uint8 _GetPurchasedTabsSize() const
Definition: Guild.h:920
const RankInfo * GetRankInfo(uint8 rankId) const
Definition: Guild.h:908

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string Guild::_GetRankName ( uint8  rankId) const
inlineprivate
2919 {
2920  if (const RankInfo* rankInfo = GetRankInfo(rankId))
2921  return rankInfo->GetName();
2922  return "<unknown>";
2923 }
const RankInfo * GetRankInfo(uint8 rankId) const
Definition: Guild.h:908

+ Here is the call graph for this function:

uint32 Guild::_GetRankRights ( uint8  rankId) const
inlineprivate
2926 {
2927  if (const RankInfo* rankInfo = GetRankInfo(rankId))
2928  return rankInfo->GetRights();
2929  return 0;
2930 }
const RankInfo * GetRankInfo(uint8 rankId) const
Definition: Guild.h:908

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint8 Guild::_GetRanksSize ( ) const
inlineprivate
907 { return uint8(m_ranks.size()); }
Ranks m_ranks
Definition: Guild.h:894
uint8_t uint8
Definition: g3dmath.h:164

+ Here is the caller graph for this function:

bool Guild::_HasRankRight ( Player const player,
uint32  right 
) const
inlineprivate
911  {
912  if (player)
913  if (Member const* member = GetMember(player->GetGUID()))
914  return (_GetRankRights(member->GetRankId()) & right) != GR_RIGHT_NONE;
915  return false;
916  }
const Member * GetMember(ObjectGuid guid) const
Definition: Guild.h:924
uint32 _GetRankRights(uint8 rankId) const
Definition: Guild.cpp:2925
Definition: Guild.h:77

+ Here is the caller graph for this function:

bool Guild::_IsLeader ( Player player) const
private
2851 {
2852  if (player->GetGUID() == m_leaderGuid)
2853  return true;
2854  if (const Member* member = GetMember(player->GetGUID()))
2855  return member->IsRank(GR_GUILDMASTER);
2856  return false;
2857 }
Definition: Guild.h:66
const Member * GetMember(ObjectGuid guid) const
Definition: Guild.h:924
ObjectGuid m_leaderGuid
Definition: Guild.h:885

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Guild::_LogBankEvent ( SQLTransaction trans,
GuildBankEventLogTypes  eventType,
uint8  tabId,
ObjectGuid::LowType  playerGuid,
uint64  itemOrMoney,
uint16  itemStackCount = 0,
uint8  destTabId = 0 
)
private
3024 {
3025  if (tabId > GUILD_BANK_MAX_TABS)
3026  return;
3027 
3028  // not logging moves within the same tab
3029  if (eventType == GUILD_BANK_LOG_MOVE_ITEM && tabId == destTabId)
3030  return;
3031 
3032  uint8 dbTabId = tabId;
3033  if (BankEventLogEntry::IsMoneyEvent(eventType))
3034  {
3035  tabId = GUILD_BANK_MAX_TABS;
3036  dbTabId = GUILD_BANK_MONEY_LOGS_TAB;
3037  }
3038  LogHolder* pLog = m_bankEventLog[tabId];
3039  pLog->AddEvent(trans, new BankEventLogEntry(m_id, pLog->GetNextGUID(), eventType, dbTabId, lowguid, itemOrMoney, itemStackCount, destTabId));
3040 
3041  sScriptMgr->OnGuildBankEvent(this, uint8(eventType), tabId, lowguid, itemOrMoney, itemStackCount, destTabId);
3042 }
LogHolder * m_bankEventLog[GUILD_BANK_MAX_TABS+1]
Definition: Guild.h:900
Definition: Guild.h:46
Definition: Guild.h:193
Definition: Guild.h:44
bool IsMoneyEvent() const
Definition: Guild.h:485
uint8_t uint8
Definition: g3dmath.h:164
ObjectGuid::LowType m_id
Definition: Guild.h:883
uint8_t uint8
Definition: Define.h:152
#define sScriptMgr
Definition: ScriptMgr.h:837
void AddEvent(SQLTransaction &trans, LogEntry *entry)
Definition: Guild.cpp:92

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Guild::_LogEvent ( GuildEventLogTypes  eventType,
ObjectGuid::LowType  playerGuid1,
ObjectGuid::LowType  playerGuid2 = UI64LIT(0),
uint8  newRank = 0 
)
inlineprivate
3014 {
3016  m_eventLog->AddEvent(trans, new EventLogEntry(m_id, m_eventLog->GetNextGUID(), eventType, playerGuid1, playerGuid2, newRank));
3018 
3019  sScriptMgr->OnGuildEvent(this, uint8(eventType), playerGuid1, playerGuid2, newRank);
3020 }
LogHolder * m_eventLog
Definition: Guild.h:899
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
uint32 GetNextGUID()
Definition: Guild.cpp:107
uint8_t uint8
Definition: g3dmath.h:164
ObjectGuid::LowType m_id
Definition: Guild.h:883
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define sScriptMgr
Definition: ScriptMgr.h:837
void AddEvent(SQLTransaction &trans, LogEntry *entry)
Definition: Guild.cpp:92
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Guild::_MemberHasTabRights ( ObjectGuid  guid,
uint8  tabId,
int32  rights 
) const
inlineprivate
3001 {
3002  if (const Member* member = GetMember(guid))
3003  {
3004  // Leader always has full rights
3005  if (member->IsRank(GR_GUILDMASTER) || m_leaderGuid == guid)
3006  return true;
3007  return (_GetRankBankTabRights(member->GetRankId(), tabId) & rights) == rights;
3008  }
3009  return false;
3010 }
Definition: Guild.h:66
const Member * GetMember(ObjectGuid guid) const
Definition: Guild.h:924
int8 _GetRankBankTabRights(uint8 rankId, uint8 tabId) const
Definition: Guild.cpp:2947
ObjectGuid m_leaderGuid
Definition: Guild.h:885

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Guild::_ModifyBankMoney ( SQLTransaction trans,
uint64  amount,
bool  add 
)
private
2871 {
2872  if (add)
2873  m_bankMoney += amount;
2874  else
2875  {
2876  // Check if there is enough money in bank.
2877  if (m_bankMoney < amount)
2878  return false;
2879  m_bankMoney -= amount;
2880  }
2881 
2883  stmt->setUInt64(0, m_bankMoney);
2884  stmt->setUInt64(1, m_id);
2885  trans->Append(stmt);
2886  return true;
2887 }
Definition: PreparedStatement.h:74
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
ObjectGuid::LowType m_id
Definition: Guild.h:883
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
uint64 m_bankMoney
Definition: Guild.h:892
Definition: CharacterDatabase.h:193

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Guild::_MoveItems ( MoveItemData pSrc,
MoveItemData pDest,
uint32  splitedAmount 
)
private
3058 {
3059  // 1. Initialize source item
3060  if (!pSrc->InitItem())
3061  return; // No source item
3062 
3063  // 2. Check source item
3064  if (!pSrc->CheckItem(splitedAmount))
3065  return; // Source item or splited amount is invalid
3066  /*
3067  if (pItemSrc->GetCount() == 0)
3068  {
3069  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!",
3070  player->GetName(), player->GetGUIDLow(), pItemSrc->GetEntry(), tabId, slotId, destTabId, destSlotId, pItemSrc->GetEntry());
3071  //return; // Commented out for now, uncomment when it's verified that this causes a crash!!
3072  }
3073  // */
3074 
3075  // 3. Check destination rights
3076  if (!pDest->HasStoreRights(pSrc))
3077  return; // Player has no rights to store item in destination
3078 
3079  // 4. Check source withdraw rights
3080  if (!pSrc->HasWithdrawRights(pDest))
3081  return; // Player has no rights to withdraw items from source
3082 
3083  // 5. Check split
3084  if (splitedAmount)
3085  {
3086  // 5.1. Clone source item
3087  if (!pSrc->CloneItem(splitedAmount))
3088  return; // Item could not be cloned
3089 
3090  // 5.2. Move splited item to destination
3091  _DoItemsMove(pSrc, pDest, true, splitedAmount);
3092  }
3093  else // 6. No split
3094  {
3095  // 6.1. Try to merge items in destination (pDest->GetItem() == NULL)
3096  if (!_DoItemsMove(pSrc, pDest, false)) // Item could not be merged
3097  {
3098  // 6.2. Try to swap items
3099  // 6.2.1. Initialize destination item
3100  if (!pDest->InitItem())
3101  return;
3102 
3103  // 6.2.2. Check rights to store item in source (opposite direction)
3104  if (!pSrc->HasStoreRights(pDest))
3105  return; // Player has no rights to store item in source (opposite direction)
3106 
3107  if (!pDest->HasWithdrawRights(pSrc))
3108  return; // Player has no rights to withdraw item from destination (opposite direction)
3109 
3110  // 6.2.3. Swap items (pDest->GetItem() != NULL)
3111  _DoItemsMove(pSrc, pDest, true);
3112  }
3113  }
3114  // 7. Send changes
3115  _SendBankContentUpdate(pSrc, pDest);
3116 }
bool _DoItemsMove(MoveItemData *pSrc, MoveItemData *pDest, bool sendError, uint32 splitedAmount=0)
Definition: Guild.cpp:3118
void _SendBankContentUpdate(MoveItemData *pSrc, MoveItemData *pDest) const
Definition: Guild.cpp:3162

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Guild::_RemoveItem ( SQLTransaction trans,
uint8  tabId,
uint8  slotId 
)
inlineprivate
3052 {
3053  if (BankTab* pTab = GetBankTab(tabId))
3054  pTab->SetItem(trans, slotId, NULL);
3055 }
arena_t NULL
Definition: jemalloc_internal.h:624
BankTab * GetBankTab(uint8 tabId)
Definition: Guild.h:921

+ Here is the call graph for this function:

void Guild::_SendBankContentUpdate ( MoveItemData pSrc,
MoveItemData pDest 
) const
private
3163 {
3164  ASSERT(pSrc->IsBank() || pDest->IsBank());
3165 
3166  uint8 tabId = 0;
3167  SlotIds slots;
3168  if (pSrc->IsBank()) // B ->
3169  {
3170  tabId = pSrc->GetContainer();
3171  slots.insert(pSrc->GetSlotId());
3172  if (pDest->IsBank()) // B -> B
3173  {
3174  // Same tab - add destination slots to collection
3175  if (pDest->GetContainer() == pSrc->GetContainer())
3176  pDest->CopySlots(slots);
3177  else // Different tabs - send second message
3178  {
3179  SlotIds destSlots;
3180  pDest->CopySlots(destSlots);
3181  _SendBankContentUpdate(pDest->GetContainer(), destSlots);
3182  }
3183  }
3184  }
3185  else if (pDest->IsBank()) // C -> B
3186  {
3187  tabId = pDest->GetContainer();
3188  pDest->CopySlots(slots);
3189  }
3190 
3191  _SendBankContentUpdate(tabId, slots);
3192 }
std::set< uint8 > SlotIds
Definition: Guild.h:318
uint8_t uint8
Definition: Define.h:152
#define ASSERT
Definition: Errors.h:55
void _SendBankContentUpdate(MoveItemData *pSrc, MoveItemData *pDest) const
Definition: Guild.cpp:3162

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Guild::_SendBankContentUpdate ( uint8  tabId,
SlotIds  slots 
) const
private
3195 {
3196  if (BankTab const* tab = GetBankTab(tabId))
3197  {
3199  packet.FullUpdate = true; // @todo
3200  packet.Tab = int32(tabId);
3201  packet.Money = m_bankMoney;
3202 
3203  for (SlotIds::const_iterator itr = slots.begin(); itr != slots.end(); ++itr)
3204  {
3205  Item const* tabItem = tab->GetItem(*itr);
3206 
3208 
3209  itemInfo.Slot = int32(*itr);
3210  itemInfo.Item.ItemID = int32(tabItem ? tabItem->GetEntry() : 0);
3211  itemInfo.Count = int32(tabItem ? tabItem->GetCount() : 0);
3212  itemInfo.Charges = int32(tabItem ? abs(tabItem->GetSpellCharges()) : 0);
3213  itemInfo.OnUseEnchantmentID = 0/*int32(tabItem->GetItemSuffixFactor())*/;
3214  itemInfo.Flags = 0;
3215  itemInfo.Locked = false;
3216 
3217  if (tabItem)
3218  {
3219  uint32 enchants = 0;
3220  for (uint32 ench = 0; ench < MAX_ENCHANTMENT_SLOT; ++ench)
3221  if (tabItem->GetEnchantmentId(EnchantmentSlot(ench)))
3222  ++enchants;
3223 
3224  itemInfo.SocketEnchant.reserve(enchants);
3225  for (uint32 ench = 0; ench < MAX_ENCHANTMENT_SLOT; ++ench)
3226  {
3227  if (uint32 enchantId = tabItem->GetEnchantmentId(EnchantmentSlot(ench)))
3228  {
3230  socketEnchant.SocketEnchantID = int32(enchantId);
3231  socketEnchant.SocketIndex = int32(ench);
3232  itemInfo.SocketEnchant.push_back(socketEnchant);
3233  }
3234  }
3235  }
3236 
3237  packet.ItemInfo.push_back(itemInfo);
3238  }
3239 
3240  for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
3241  if (_MemberHasTabRights(itr->second->GetGUID(), tabId, GUILD_BANK_RIGHT_VIEW_TAB))
3242  if (Player* player = itr->second->FindPlayer())
3243  {
3244  packet.WithdrawalsRemaining = int32(_GetMemberRemainingSlots(itr->second, tabId));
3245  player->GetSession()->SendPacket(packet.Write());
3246  }
3247 
3248  TC_LOG_DEBUG("guild", "WORLD: Sent SMSG_GUILD_BANK_QUERY_RESULTS");
3249  }
3250 }
G3D::Matrix abs(const G3D::Matrix &M)
Definition: Matrix.h:632
WorldPackets::Item::ItemInstance Item
Definition: GuildPackets.h:789
uint32 GetCount() const
Definition: Item.h:322
int32 Charges
Definition: GuildPackets.h:793
int32 GetSpellCharges(uint8 index=0) const
Definition: Item.h:364
Definition: GuildPackets.h:807
int32 OnUseEnchantmentID
Definition: GuildPackets.h:794
std::vector< GuildBankSocketEnchant > SocketEnchant
Definition: GuildPackets.h:797
EnchantmentSlot
Definition: Item.h:172
int32 Count
Definition: GuildPackets.h:791
BankTab * GetBankTab(uint8 tabId)
Definition: Guild.h:921
int32 Flags
Definition: GuildPackets.h:795
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Item.h:190
int32 Slot
Definition: GuildPackets.h:790
bool Locked
Definition: GuildPackets.h:796
int32 _GetMemberRemainingSlots(Member const *member, uint8 tabId) const
Definition: Guild.cpp:2954
int32 Tab
Definition: GuildPackets.h:817
WorldPacket const * Write() override
Definition: GuildPackets.cpp:596
Definition: GuildPackets.h:781
Definition: Item.h:259
Members m_members
Definition: Guild.h:895
uint32_t uint32
Definition: Define.h:150
uint64 Money
Definition: GuildPackets.h:818
std::vector< GuildBankItemInfo > ItemInfo
Definition: GuildPackets.h:814
int32_t int32
Definition: g3dmath.h:167
bool _MemberHasTabRights(ObjectGuid guid, uint8 tabId, int32 rights) const
Definition: Guild.cpp:3000
Definition: Guild.h:181
uint32 GetEntry() const
Definition: Object.h:107
uint64 m_bankMoney
Definition: Guild.h:892
uint32 ItemID
Definition: ItemPackets.h:46
bool FullUpdate
Definition: GuildPackets.h:819
int32 WithdrawalsRemaining
Definition: GuildPackets.h:816
uint32 GetEnchantmentId(EnchantmentSlot slot) const
Definition: Item.h:351

+ Here is the call graph for this function:

void Guild::_SetLeaderGUID ( Member pLeader)
private
2890 {
2891  if (!pLeader)
2892  return;
2893 
2894  m_leaderGuid = pLeader->GetGUID();
2895  pLeader->ChangeRank(GR_GUILDMASTER);
2896 
2898  stmt->setUInt64(0, m_leaderGuid.GetCounter());
2899  stmt->setUInt64(1, m_id);
2900  CharacterDatabase.Execute(stmt);
2901 }
Definition: Guild.h:66
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Definition: PreparedStatement.h:74
ObjectGuid m_leaderGuid
Definition: Guild.h:885
Definition: CharacterDatabase.h:188
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
ObjectGuid::LowType m_id
Definition: Guild.h:883
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
LowType GetCounter() const
Definition: ObjectGuid.h:221

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Guild::_SetRankBankMoneyPerDay ( uint8  rankId,
uint32  moneyPerDay 
)
private
2904 {
2905  if (RankInfo* rankInfo = GetRankInfo(rankId))
2906  rankInfo->SetBankMoneyPerDay(moneyPerDay);
2907 }
const RankInfo * GetRankInfo(uint8 rankId) const
Definition: Guild.h:908

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Guild::_SetRankBankTabRightsAndSlots ( uint8  rankId,
GuildBankRightsAndSlots  rightsAndSlots,
bool  saveToDB = true 
)
private
2910 {
2911  if (rightsAndSlots.GetTabId() >= _GetPurchasedTabsSize())
2912  return;
2913 
2914  if (RankInfo* rankInfo = GetRankInfo(rankId))
2915  rankInfo->SetBankTabSlotsAndRights(rightsAndSlots, saveToDB);
2916 }
uint8 _GetPurchasedTabsSize() const
Definition: Guild.h:920
const RankInfo * GetRankInfo(uint8 rankId) const
Definition: Guild.h:908
int8 GetTabId() const
Definition: Guild.h:306

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Guild::_UpdateAccountsNumber ( )
private
2838 {
2839  // We use a set to be sure each element will be unique
2840  std::set<uint32> accountsIdSet;
2841  for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
2842  accountsIdSet.insert(itr->second->GetAccountId());
2843 
2844  m_accountsNumber = accountsIdSet.size();
2845 }
uint32 m_accountsNumber
Definition: Guild.h:891
Members m_members
Definition: Guild.h:895

+ Here is the caller graph for this function:

void Guild::_UpdateMemberWithdrawSlots ( SQLTransaction trans,
ObjectGuid  guid,
uint8  tabId 
)
inlineprivate
2990 {
2991  if (Member* member = GetMember(guid))
2992  {
2993  uint8 rankId = member->GetRankId();
2994  if (rankId != GR_GUILDMASTER
2995  && member->GetBankWithdrawValue(tabId) < _GetRankBankTabSlotsPerDay(rankId, tabId))
2996  member->UpdateBankWithdrawValue(trans, tabId, 1);
2997  }
2998 }
Definition: Guild.h:66
int32 _GetRankBankTabSlotsPerDay(uint8 rankId, uint8 tabId) const
Definition: Guild.cpp:2939
const Member * GetMember(ObjectGuid guid) const
Definition: Guild.h:924
uint8_t uint8
Definition: Define.h:152

+ Here is the call graph for this function:

void Guild::AddGuildNews ( uint8  type,
ObjectGuid  guid,
uint32  flags,
uint32  value 
)
3369 {
3370  NewsLogEntry* news = new NewsLogEntry(m_id, m_newsLog->GetNextGUID(), GuildNews(type), guid, flags, value);
3371 
3373  m_newsLog->AddEvent(trans, news);
3375 
3376  WorldPackets::Guild::GuildNews newsPacket;
3377  newsPacket.NewsEvents.reserve(1);
3378  news->WritePacket(newsPacket);
3379  BroadcastPacket(newsPacket.Write());
3380 }
Definition: GuildPackets.h:932
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
void BroadcastPacket(WorldPacket const *packet) const
Definition: Guild.cpp:2520
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
GuildNews
Definition: Guild.h:232
uint32 GetNextGUID()
Definition: Guild.cpp:107
WorldPacket const * Write() override
Definition: GuildPackets.cpp:763
ObjectGuid::LowType m_id
Definition: Guild.h:883
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
const FieldDescriptor value
Definition: descriptor.h:1522
uint8 flags
Definition: DisableMgr.cpp:44
std::vector< GuildNewsEvent > NewsEvents
Definition: GuildPackets.h:939
LogHolder * m_newsLog
Definition: Guild.h:901
void AddEvent(SQLTransaction &trans, LogEntry *entry)
Definition: Guild.cpp:92
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

bool Guild::AddMember ( ObjectGuid  guid,
uint8  rankId = GUILD_RANK_NONE 
)
2561 {
2563  // Player cannot be in guild
2564  if (player)
2565  {
2566  if (player->GetGuildId())
2567  return false;
2568  }
2569  else if (Player::GetGuildIdFromDB(guid))
2570  return false;
2571 
2572  // Remove all player signs from another petitions
2573  // This will be prevent attempt to join many guilds and corrupt guild data integrity
2574  Player::RemovePetitionsAndSigns(guid);
2575 
2576  ObjectGuid::LowType lowguid = guid.GetCounter();
2577 
2578  // If rank was not passed, assign lowest possible rank
2579  if (rankId == GUILD_RANK_NONE)
2580  rankId = _GetLowestRankId();
2581 
2582  Member* member = new Member(m_id, guid, rankId);
2583  std::string name;
2584  if (player)
2585  {
2586  m_members[guid] = member;
2587  player->SetInGuild(m_id);
2588  player->SetGuildIdInvited(UI64LIT(0));
2589  player->SetRank(rankId);
2590  player->SetGuildLevel(GetLevel());
2591  SendLoginInfo(player->GetSession());
2592  name = player->GetName();
2593  }
2594  else
2595  {
2596  member->ResetFlags();
2597 
2598  bool ok = false;
2599  // Player must exist
2601  stmt->setUInt64(0, lowguid);
2602  if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
2603  {
2604  Field* fields = result->Fetch();
2605  name = fields[0].GetString();
2606  member->SetStats(
2607  name,
2608  fields[1].GetUInt8(),
2609  fields[2].GetUInt8(),
2610  fields[3].GetUInt8(),
2611  fields[4].GetUInt16(),
2612  fields[5].GetUInt32(),
2613  0);
2614 
2615  ok = member->CheckStats();
2616  }
2617 
2618  if (!ok)
2619  {
2620  delete member;
2621  return false;
2622  }
2623  m_members[guid] = member;
2624  }
2625 
2626  SQLTransaction trans(NULL);
2627  member->SaveToDB(trans);
2628 
2631 
2632  WorldPackets::Guild::GuildEventPlayerJoined joinNotificationPacket;
2633  joinNotificationPacket.Guid = guid;
2634  joinNotificationPacket.Name = name;
2635  joinNotificationPacket.VirtualRealmAddress = GetVirtualRealmAddress();
2636  BroadcastPacket(joinNotificationPacket.Write());
2637 
2638  sGuildFinderMgr->RemoveAllMembershipRequestsFromPlayer(guid);
2639 
2640  // Call scripts if member was succesfully added (and stored to database)
2641  sScriptMgr->OnGuildAddMember(this, player, rankId);
2642 
2643  return true;
2644 }
uint32 VirtualRealmAddress
Definition: GuildPackets.h:262
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
uint8 _GetLowestRankId() const
Definition: Guild.h:918
Class used to access individual fields of database query result.
Definition: Field.h:56
#define UI64LIT(N)
Definition: Define.h:138
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Guild.h:206
void BroadcastPacket(WorldPacket const *packet) const
Definition: Guild.cpp:2520
uint64 LowType
Definition: ObjectGuid.h:199
std::string Name
Definition: GuildPackets.h:261
Definition: PreparedStatement.h:74
uint8 GetLevel() const
Definition: Guild.h:872
Members m_members
Definition: Guild.h:895
Definition: Guild.h:49
Definition: CharacterDatabase.h:198
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
WorldPacket const * Write() override
Definition: GuildPackets.cpp:218
void _LogEvent(GuildEventLogTypes eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2=UI64LIT(0), uint8 newRank=0)
Definition: Guild.cpp:3013
Definition: GuildPackets.h:253
ObjectGuid::LowType m_id
Definition: Guild.h:883
void _UpdateAccountsNumber()
Definition: Guild.cpp:2837
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
uint32 GetVirtualRealmAddress()
Definition: World.cpp:3487
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define sScriptMgr
Definition: ScriptMgr.h:837
#define sGuildFinderMgr
Definition: GuildFinderMgr.h:271
ObjectGuid Guid
Definition: GuildPackets.h:260
std::string GetString() const
Definition: Field.h:276
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215
void SendLoginInfo(WorldSession *session)
Definition: Guild.cpp:2130
LowType GetCounter() const
Definition: ObjectGuid.h:221
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Guild::BroadcastAddonToGuild ( WorldSession session,
bool  officerOnly,
std::string const msg,
std::string const prefix 
) const
2497 {
2498  if (session && session->GetPlayer() && _HasRankRight(session->GetPlayer(), officerOnly ? GR_RIGHT_OFFCHATSPEAK : GR_RIGHT_GCHATSPEAK))
2499  {
2500  WorldPackets::Chat::Chat packet;
2501  packet.Initialize(officerOnly ? CHAT_MSG_OFFICER : CHAT_MSG_GUILD, LANG_ADDON, session->GetPlayer(), nullptr, msg, 0, "", DEFAULT_LOCALE, prefix);
2502  WorldPacket const* data = packet.Write();
2503  for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
2504  if (Player* player = itr->second->FindPlayer())
2505  if (player->GetSession() && _HasRankRight(player, officerOnly ? GR_RIGHT_OFFCHATLISTEN : GR_RIGHT_GCHATLISTEN) &&
2506  !player->GetSocial()->HasIgnore(session->GetPlayer()->GetGUID()) &&
2507  player->GetSession()->IsAddonRegistered(prefix))
2508  player->GetSession()->SendPacket(data);
2509  }
2510 }
Definition: Guild.h:81
Definition: Guild.h:80
Definition: ChatPackets.h:150
Player * GetPlayer() const
Definition: WorldSession.h:927
WorldPacket const * Write() override
Definition: ChatPackets.cpp:162
Definition: SharedDefines.h:4236
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:104
Members m_members
Definition: Guild.h:895
Definition: Guild.h:78
bool _HasRankRight(Player const *player, uint32 right) const
Definition: Guild.h:910
Definition: SharedDefines.h:4235
Definition: Guild.h:79
#define DEFAULT_LOCALE
Definition: Common.h:134
Definition: WorldPacket.h:26
Definition: SharedDefines.h:985

+ Here is the call graph for this function:

void Guild::BroadcastPacket ( WorldPacket const packet) const
2521 {
2522  for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
2523  if (Player* player = itr->second->FindPlayer())
2524  player->GetSession()->SendPacket(packet);
2525 }
Members m_members
Definition: Guild.h:895

+ Here is the caller graph for this function:

void Guild::BroadcastPacketIfTrackingAchievement ( WorldPacket const packet,
uint32  criteriaId 
) const
2528 {
2529  for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
2530  if (itr->second->IsTrackingCriteriaId(criteriaId))
2531  if (Player* player = itr->second->FindPlayer())
2532  player->GetSession()->SendPacket(packet);
2533 }
Members m_members
Definition: Guild.h:895
void Guild::BroadcastPacketToRank ( WorldPacket const packet,
uint8  rankId 
) const
2513 {
2514  for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
2515  if (itr->second->IsRank(rankId))
2516  if (Player* player = itr->second->FindConnectedPlayer())
2517  player->GetSession()->SendPacket(packet);
2518 }
Members m_members
Definition: Guild.h:895

+ Here is the caller graph for this function:

void Guild::BroadcastToGuild ( WorldSession session,
bool  officerOnly,
std::string const msg,
uint32  language = LANG_UNIVERSAL 
) const
2482 {
2483  if (session && session->GetPlayer() && _HasRankRight(session->GetPlayer(), officerOnly ? GR_RIGHT_OFFCHATSPEAK : GR_RIGHT_GCHATSPEAK))
2484  {
2485  WorldPackets::Chat::Chat packet;
2486  packet.Initialize(officerOnly ? CHAT_MSG_OFFICER : CHAT_MSG_GUILD, Language(language), session->GetPlayer(), nullptr, msg);
2487  WorldPacket const* data = packet.Write();
2488  for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
2489  if (Player* player = itr->second->FindConnectedPlayer())
2490  if (player->GetSession() && _HasRankRight(player, officerOnly ? GR_RIGHT_OFFCHATLISTEN : GR_RIGHT_GCHATLISTEN) &&
2491  !player->GetSocial()->HasIgnore(session->GetPlayer()->GetGUID()))
2492  player->GetSession()->SendPacket(data);
2493  }
2494 }
Definition: Guild.h:81
Definition: Guild.h:80
Definition: ChatPackets.h:150
Player * GetPlayer() const
Definition: WorldSession.h:927
WorldPacket const * Write() override
Definition: ChatPackets.cpp:162
Language
Definition: SharedDefines.h:959
Definition: SharedDefines.h:4236
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:104
Members m_members
Definition: Guild.h:895
Definition: Guild.h:78
bool _HasRankRight(Player const *player, uint32 right) const
Definition: Guild.h:910
Definition: SharedDefines.h:4235
Definition: Guild.h:79
Definition: WorldPacket.h:26

+ Here is the call graph for this function:

template<class Do >
void Guild::BroadcastWorker ( Do &  _do,
Player except = NULL 
)
inline
846  {
847  for (Members::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
848  if (Player* player = itr->second->FindConnectedPlayer())
849  if (player != except)
850  _do(player);
851  }
Members m_members
Definition: Guild.h:895
bool Guild::ChangeMemberRank ( ObjectGuid  guid,
uint8  newRank 
)
2709 {
2710  if (newRank <= _GetLowestRankId()) // Validate rank (allow only existing ranks)
2711  if (Member* member = GetMember(guid))
2712  {
2713  member->ChangeRank(newRank);
2714  return true;
2715  }
2716  return false;
2717 }
const Member * GetMember(ObjectGuid guid) const
Definition: Guild.h:924
uint8 _GetLowestRankId() const
Definition: Guild.h:918

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Guild::Create ( Player pLeader,
std::string const name 
)
1079 {
1080  // Check if guild with such name already exists
1081  if (sGuildMgr->GetGuildByName(name))
1082  return false;
1083 
1084  WorldSession* pLeaderSession = pLeader->GetSession();
1085  if (!pLeaderSession)
1086  return false;
1087 
1088  m_id = sGuildMgr->GenerateGuildId();
1089  m_leaderGuid = pLeader->GetGUID();
1090  m_name = name;
1091  m_info = "";
1092  m_motd = "No message set.";
1093  m_bankMoney = 0;
1094  m_createdDate = ::time(NULL);
1095  _level = 1;
1097 
1098  TC_LOG_DEBUG("guild", "GUILD: creating guild [%s] for leader %s (%s)",
1099  name.c_str(), pLeader->GetName().c_str(), m_leaderGuid.ToString().c_str());
1100 
1102 
1104  stmt->setUInt64(0, m_id);
1105  trans->Append(stmt);
1106 
1107  uint8 index = 0;
1109  stmt->setUInt64( index, m_id);
1110  stmt->setString(++index, name);
1111  stmt->setUInt64(++index, m_leaderGuid.GetCounter());
1112  stmt->setString(++index, m_info);
1113  stmt->setString(++index, m_motd);
1114  stmt->setUInt64(++index, uint32(m_createdDate));
1115  stmt->setUInt32(++index, m_emblemInfo.GetStyle());
1116  stmt->setUInt32(++index, m_emblemInfo.GetColor());
1117  stmt->setUInt32(++index, m_emblemInfo.GetBorderStyle());
1118  stmt->setUInt32(++index, m_emblemInfo.GetBorderColor());
1119  stmt->setUInt32(++index, m_emblemInfo.GetBackgroundColor());
1120  stmt->setUInt64(++index, m_bankMoney);
1121  trans->Append(stmt);
1122 
1124  _CreateDefaultGuildRanks(pLeaderSession->GetSessionDbLocaleIndex()); // Create default ranks
1125  bool ret = AddMember(m_leaderGuid, GR_GUILDMASTER); // Add guildmaster
1126 
1127  if (ret)
1128  {
1129  Member* leader = GetMember(m_leaderGuid);
1130  if (leader)
1131  SendEventNewLeader(leader, NULL);
1132 
1133  sScriptMgr->OnGuildCreate(this, pLeader, name);
1134  }
1135 
1136  return ret;
1137 }
Definition: Guild.h:66
Definition: CharacterDatabase.h:158
Definition: CharacterDatabase.h:163
EmblemInfo m_emblemInfo
Definition: Guild.h:890
LocaleConstant GetSessionDbLocaleIndex() const
Definition: WorldSession.h:1060
const Member * GetMember(ObjectGuid guid) const
Definition: Guild.h:924
#define sGuildMgr
Definition: GuildMgr.h:61
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
arena_t NULL
Definition: jemalloc_internal.h:624
time_t m_createdDate
Definition: Guild.h:888
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: PreparedStatement.h:74
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
ObjectGuid m_leaderGuid
Definition: Guild.h:885
uint32 GetBorderColor() const
Definition: Guild.h:277
uint32 GetBorderStyle() const
Definition: Guild.h:276
std::string m_motd
Definition: Guild.h:886
uint32 GetColor() const
Definition: Guild.h:275
void SendEventNewLeader(Member *newLeader, Member *oldLeader, bool isSelfPromoted=false)
Definition: Guild.cpp:2195
std::string m_name
Definition: Guild.h:884
uint32 GetStyle() const
Definition: Guild.h:274
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
bool AddMember(ObjectGuid guid, uint8 rankId=GUILD_RANK_NONE)
Definition: Guild.cpp:2560
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
void _CreateLogHolders()
Definition: Guild.cpp:2768
ObjectGuid::LowType m_id
Definition: Guild.h:883
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
uint8_t uint8
Definition: Define.h:152
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define sScriptMgr
Definition: ScriptMgr.h:837
uint64 m_bankMoney
Definition: Guild.h:892
Player session in the World.
Definition: WorldSession.h:882
uint32_t uint32
Definition: g3dmath.h:168
uint8 _level
Definition: Guild.h:904
uint32 GetBackgroundColor() const
Definition: Guild.h:278
std::string m_info
Definition: Guild.h:887
std::string ToString() const
Definition: ObjectGuid.cpp:99
void _CreateDefaultGuildRanks(LocaleConstant loc)
Definition: Guild.cpp:2800
LowType GetCounter() const
Definition: ObjectGuid.h:221
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Guild::DeleteMember ( ObjectGuid  guid,
bool  isDisbanding = false,
bool  isKicked = false,
bool  canDeleteGuild = false 
)
2647 {
2648  // Guild master can be deleted when loading guild and guid doesn't exist in characters table
2649  // or when he is removed from guild by gm command
2650  if (m_leaderGuid == guid && !isDisbanding)
2651  {
2652  Member* oldLeader = NULL;
2653  Member* newLeader = NULL;
2654  for (Guild::Members::iterator i = m_members.begin(); i != m_members.end(); ++i)
2655  {
2656  if (i->first == guid)
2657  oldLeader = i->second;
2658  else if (!newLeader || newLeader->GetRankId() > i->second->GetRankId())
2659  newLeader = i->second;
2660  }
2661 
2662  if (!newLeader)
2663  {
2664  Disband();
2665  if (canDeleteGuild)
2666  delete this;
2667  return;
2668  }
2669 
2670  _SetLeaderGUID(newLeader);
2671 
2672  // If player not online data in data field will be loaded from guild tabs no need to update it !!
2673  if (Player* newLeaderPlayer = newLeader->FindPlayer())
2674  newLeaderPlayer->SetRank(GR_GUILDMASTER);
2675 
2676  // If leader does not exist (at guild loading with deleted leader) do not send broadcasts
2677  if (oldLeader)
2678  {
2679  SendEventNewLeader(newLeader, oldLeader, true);
2680  SendEventPlayerLeft(oldLeader);
2681  }
2682  }
2683  // Call script on remove before member is actually removed from guild (and database)
2684  sScriptMgr->OnGuildRemoveMember(this, guid, isDisbanding, isKicked);
2685 
2686  if (Member* member = GetMember(guid))
2687  delete member;
2688  m_members.erase(guid);
2689 
2690  // If player not online data in data field will be loaded from guild tabs no need to update it !!
2692  if (player)
2693  {
2694  player->SetInGuild(UI64LIT(0));
2695  player->SetRank(0);
2696  player->SetGuildLevel(0);
2697 
2698  for (GuildPerkSpellsEntry const* entry : sGuildPerkSpellsStore)
2699  if (entry->GuildLevel <= GetLevel())
2700  player->RemoveSpell(entry->SpellID, false, false);
2701  }
2702 
2704  if (!isDisbanding)
2706 }
Definition: Guild.h:66
const Member * GetMember(ObjectGuid guid) const
Definition: Guild.h:924
#define UI64LIT(N)
Definition: Define.h:138
arena_t NULL
Definition: jemalloc_internal.h:624
void _DeleteMemberFromDB(ObjectGuid::LowType lowguid) const
Definition: Guild.h:945
void Disband()
Definition: Guild.cpp:1140
ObjectGuid m_leaderGuid
Definition: Guild.h:885
uint8 GetLevel() const
Definition: Guild.h:872
Definition: DB2Structure.h:579
Members m_members
Definition: Guild.h:895
void SendEventNewLeader(Member *newLeader, Member *oldLeader, bool isSelfPromoted=false)
Definition: Guild.cpp:2195
void _SetLeaderGUID(Member *pLeader)
Definition: Guild.cpp:2889
DB2Storage< GuildPerkSpellsEntry > sGuildPerkSpellsStore("GuildPerkSpells.db2", GuildPerkSpellsFormat, HOTFIX_SEL_GUILD_PERK_SPELLS)
void _UpdateAccountsNumber()
Definition: Guild.cpp:2837
void SendEventPlayerLeft(Member *leaver, Member *remover=nullptr, bool isRemoved=false)
Definition: Guild.cpp:2216
#define sScriptMgr
Definition: ScriptMgr.h:837
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215
LowType GetCounter() const
Definition: ObjectGuid.h:221

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Guild::Disband ( )
1141 {
1142  // Call scripts before guild data removed from database
1143  sScriptMgr->OnGuildDisband(this);
1144 
1146  BroadcastPacket(packet.Write());
1147 
1148  // Remove all members
1149  while (!m_members.empty())
1150  {
1151  Members::const_iterator itr = m_members.begin();
1152  DeleteMember(itr->second->GetGUID(), true);
1153  }
1154 
1156 
1158  stmt->setUInt64(0, m_id);
1159  trans->Append(stmt);
1160 
1162  stmt->setUInt64(0, m_id);
1163  trans->Append(stmt);
1164 
1166  stmt->setUInt64(0, m_id);
1167  trans->Append(stmt);
1168 
1169  // Free bank tab used memory and delete items stored in them
1170  _DeleteBankItems(trans, true);
1171 
1173  stmt->setUInt64(0, m_id);
1174  trans->Append(stmt);
1175 
1177  stmt->setUInt64(0, m_id);
1178  trans->Append(stmt);
1179 
1181  stmt->setUInt64(0, m_id);
1182  trans->Append(stmt);
1183 
1185  stmt->setUInt64(0, m_id);
1186  trans->Append(stmt);
1187 
1189 
1190  sGuildFinderMgr->DeleteGuild(GetGUID());
1191 
1192  sGuildMgr->RemoveGuild(m_id);
1193 }
#define sGuildMgr
Definition: GuildMgr.h:61
Definition: CharacterDatabase.h:179
Definition: CharacterDatabase.h:175
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
void BroadcastPacket(WorldPacket const *packet) const
Definition: Guild.cpp:2520
Definition: PreparedStatement.h:74
void DeleteMember(ObjectGuid guid, bool isDisbanding=false, bool isKicked=false, bool canDeleteGuild=false)
Definition: Guild.cpp:2646
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
Definition: CharacterDatabase.h:159
WorldPacket const * Write() override
Definition: GuildPackets.h:298
Members m_members
Definition: Guild.h:895
Definition: GuildPackets.h:293
Definition: CharacterDatabase.h:169
ObjectGuid GetGUID() const
Definition: Guild.h:764
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
ObjectGuid::LowType m_id
Definition: Guild.h:883
Definition: CharacterDatabase.h:173
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define sScriptMgr
Definition: ScriptMgr.h:837
#define sGuildFinderMgr
Definition: GuildFinderMgr.h:271
Definition: CharacterDatabase.h:182
void _DeleteBankItems(SQLTransaction &trans, bool removeItemsFromDB=false)
Definition: Guild.cpp:2859
Definition: CharacterDatabase.h:165
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

AchievementMgr<Guild>& Guild::GetAchievementMgr ( )
inline
868 { return m_achievementMgr; }
AchievementMgr< Guild > m_achievementMgr
Definition: Guild.h:902

+ Here is the caller graph for this function:

AchievementMgr<Guild> const& Guild::GetAchievementMgr ( ) const
inline
869 { return m_achievementMgr; }
AchievementMgr< Guild > m_achievementMgr
Definition: Guild.h:902
uint64 Guild::GetBankMoney ( ) const
inline
770 { return m_bankMoney; }
uint64 m_bankMoney
Definition: Guild.h:892

+ Here is the caller graph for this function:

BankTab* Guild::GetBankTab ( uint8  tabId)
inlineprivate
921 { return tabId < m_bankTabs.size() ? m_bankTabs[tabId] : NULL; }
BankTabs m_bankTabs
Definition: Guild.h:896
arena_t NULL
Definition: jemalloc_internal.h:624

+ Here is the caller graph for this function:

const BankTab* Guild::GetBankTab ( uint8  tabId) const
inlineprivate
922 { return tabId < m_bankTabs.size() ? m_bankTabs[tabId] : NULL; }
BankTabs m_bankTabs
Definition: Guild.h:896
arena_t NULL
Definition: jemalloc_internal.h:624
time_t Guild::GetCreatedDate ( ) const
inline
769 { return m_createdDate; }
time_t m_createdDate
Definition: Guild.h:888

+ Here is the caller graph for this function:

EmblemInfo const& Guild::GetEmblemInfo ( ) const
inline
876 { return m_emblemInfo; }
EmblemInfo m_emblemInfo
Definition: Guild.h:890

+ Here is the caller graph for this function:

ObjectGuid Guild::GetGUID ( ) const
inline
764 { return ObjectGuid::Create<HighGuid::Guild>(m_id); }
ObjectGuid::LowType m_id
Definition: Guild.h:883

+ Here is the caller graph for this function:

ObjectGuid::LowType Guild::GetId ( ) const
inline
763 { return m_id; }
ObjectGuid::LowType m_id
Definition: Guild.h:883

+ Here is the caller graph for this function:

std::string const& Guild::GetInfo ( ) const
inline
768 { return m_info; }
std::string m_info
Definition: Guild.h:887

+ Here is the caller graph for this function:

ObjectGuid Guild::GetLeaderGUID ( ) const
inline
765 { return m_leaderGuid; }
ObjectGuid m_leaderGuid
Definition: Guild.h:885

+ Here is the caller graph for this function:

uint8 Guild::GetLevel ( ) const
inline
872 { return _level; }
uint8 _level
Definition: Guild.h:904

+ Here is the caller graph for this function:

const Member* Guild::GetMember ( ObjectGuid  guid) const
inlineprivate
925  {
926  Members::const_iterator itr = m_members.find(guid);
927  return itr != m_members.end() ? itr->second : NULL;
928  }
arena_t NULL
Definition: jemalloc_internal.h:624
Members m_members
Definition: Guild.h:895

+ Here is the caller graph for this function:

Member* Guild::GetMember ( ObjectGuid  guid)
inlineprivate
931  {
932  Members::iterator itr = m_members.find(guid);
933  return itr != m_members.end() ? itr->second : NULL;
934  }
arena_t NULL
Definition: jemalloc_internal.h:624
Members m_members
Definition: Guild.h:895
Member* Guild::GetMember ( std::string const name)
inlineprivate
937  {
938  for (Members::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
939  if (itr->second->GetName() == name)
940  return itr->second;
941 
942  return NULL;
943  }
arena_t NULL
Definition: jemalloc_internal.h:624
Members m_members
Definition: Guild.h:895
uint32 Guild::GetMembersCount ( ) const
inline
859 { return uint32(m_members.size()); }
Members m_members
Definition: Guild.h:895
uint32_t uint32
Definition: g3dmath.h:168

+ Here is the caller graph for this function:

std::string const& Guild::GetMOTD ( ) const
inline
767 { return m_motd; }
std::string m_motd
Definition: Guild.h:886

+ Here is the caller graph for this function:

std::string const& Guild::GetName ( ) const
inline
766 { return m_name; }
std::string m_name
Definition: Guild.h:884

+ Here is the caller graph for this function:

const RankInfo* Guild::GetRankInfo ( uint8  rankId) const
inlineprivate
908 { return rankId < _GetRanksSize() ? &m_ranks[rankId] : NULL; }
arena_t NULL
Definition: jemalloc_internal.h:624
uint8 _GetRanksSize() const
Definition: Guild.h:907
Ranks m_ranks
Definition: Guild.h:894

+ Here is the caller graph for this function:

RankInfo* Guild::GetRankInfo ( uint8  rankId)
inlineprivate
909 { return rankId < _GetRanksSize() ? &m_ranks[rankId] : NULL; }
arena_t NULL
Definition: jemalloc_internal.h:624
uint8 _GetRanksSize() const
Definition: Guild.h:907
Ranks m_ranks
Definition: Guild.h:894
void Guild::HandleAcceptMember ( WorldSession session)
1671 {
1672  Player* player = session->GetPlayer();
1673  if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) &&
1674  player->GetTeam() != ObjectMgr::GetPlayerTeamByGUID(GetLeaderGUID()))
1675  return;
1676 
1677  AddMember(player->GetGUID());
1678 }
ObjectGuid GetLeaderGUID() const
Definition: Guild.h:765
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sWorld
Definition: World.h:887
bool AddMember(ObjectGuid guid, uint8 rankId=GUILD_RANK_NONE)
Definition: Guild.cpp:2560
static uint32 GetPlayerTeamByGUID(ObjectGuid const &guid)
Definition: ObjectMgr.cpp:2294

+ Here is the call graph for this function:

void Guild::HandleAddNewRank ( WorldSession session,
std::string const name 
)
1837 {
1838  uint8 size = _GetRanksSize();
1839  if (size >= GUILD_RANKS_MAX_COUNT)
1840  return;
1841 
1842  // Only leader can add new rank
1843  if (_IsLeader(session->GetPlayer()))
1844  {
1846  {
1848  BroadcastPacket(eventPacket.Write());
1849  }
1850  }
1851 }
bool _IsLeader(Player *player) const
Definition: Guild.cpp:2850
WorldPacket const * Write() override
Definition: GuildPackets.h:280
Player * GetPlayer() const
Definition: WorldSession.h:927
void BroadcastPacket(WorldPacket const *packet) const
Definition: Guild.cpp:2520
uint8 _GetRanksSize() const
Definition: Guild.h:907
Definition: Guild.h:78
bool _CreateRank(std::string const &name, uint32 rights)
Definition: Guild.cpp:2817
Definition: Guild.h:79
uint8_t uint8
Definition: Define.h:152
Definition: GuildPackets.h:275
Definition: Guild.h:48

+ Here is the call graph for this function:

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

Hack to force client to update permissions

1558 {
1559  Player* player = session->GetPlayer();
1560  if (!player)
1561  return;
1562 
1563  Member const* member = GetMember(player->GetGUID());
1564  if (!member)
1565  return;
1566 
1568  return;
1569 
1570  if (tabId != _GetPurchasedTabsSize())
1571  return;
1572 
1573  // Do not get money for bank tabs that the GM bought, we had to buy them already.
1574  // This is just a speedup check, GetGuildBankTabPrice will return 0.
1575  if (tabId < GUILD_BANK_MAX_TABS - 2) // 7th tab is actually the 6th
1576  {
1577  uint32 tabCost = _GetGuildBankTabPrice(tabId) * GOLD;
1578  if (!tabCost)
1579  return;
1580 
1581  if (!player->HasEnoughMoney(uint64(tabCost))) // Should not happen, this is checked by client
1582  return;
1583 
1584  player->ModifyMoney(-int64(tabCost));
1585  }
1586 
1588 
1590  BroadcastPacket(packet.Write());
1591 
1592  SendPermissions(session);
1593 }
const Member * GetMember(ObjectGuid guid) const
Definition: Guild.h:924
uint32 _GetGuildBankTabPrice(uint8 tabId)
Definition: Guild.cpp:39
WorldPacket const * Write() override
Definition: GuildPackets.h:365
Player * GetPlayer() const
Definition: WorldSession.h:927
void BroadcastPacket(WorldPacket const *packet) const
Definition: Guild.cpp:2520
Definition: Guild.h:44
uint8 _GetPurchasedTabsSize() const
Definition: Guild.h:920
Definition: GuildPackets.h:360
uint32_t uint32
Definition: Define.h:150
uint64_t uint64
Definition: Define.h:149
Definition: SharedDefines.h:232
int64_t int64
Definition: g3dmath.h:169
void _CreateNewBankTab()
Definition: Guild.cpp:2776
void SendPermissions(WorldSession *session) const
Definition: Guild.cpp:2088

+ Here is the call graph for this function:

void Guild::HandleDelete ( WorldSession session)
1963 {
1964  // Only leader can disband guild
1965  if (_IsLeader(session->GetPlayer()))
1966  {
1967  Disband();
1968  TC_LOG_DEBUG("guild", "%s successfully deleted", GetGUID().ToString().c_str());
1969  delete this;
1970  }
1971 }
bool _IsLeader(Player *player) const
Definition: Guild.cpp:2850
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
void Disband()
Definition: Guild.cpp:1140
string ToString(int i)
Definition: strutil.h:491
ObjectGuid GetGUID() const
Definition: Guild.h:764

+ Here is the call graph for this function:

void Guild::HandleGuildPartyRequest ( WorldSession session)
1974 {
1975  Player* player = session->GetPlayer();
1976  Group* group = player->GetGroup();
1977 
1978  // Make sure player is a member of the guild and that he is in a group.
1979  if (!IsMember(player->GetGUID()) || !group)
1980  return;
1981 
1982  WorldPackets::Guild::GuildPartyState partyStateResponse;
1983  partyStateResponse.InGuildParty = (player->GetMap()->GetOwnerGuildId(player->GetTeam()) == GetId());
1984  partyStateResponse.NumMembers = 0;
1985  partyStateResponse.NumRequired = 0;
1986  partyStateResponse.GuildXPEarnedMult = 0.0f;
1987  session->SendPacket(partyStateResponse.Write());
1988 
1989  TC_LOG_DEBUG("guild", "SMSG_GUILD_PARTY_STATE_RESPONSE [%s]", session->GetPlayerInfo().c_str());
1990 }
int32 NumRequired
Definition: GuildPackets.h:657
float GuildXPEarnedMult
Definition: GuildPackets.h:655
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
WorldPacket const * Write() override
Definition: GuildPackets.cpp:500
int32 NumMembers
Definition: GuildPackets.h:656
bool InGuildParty
Definition: GuildPackets.h:658
ObjectGuid::LowType GetId() const
Definition: Guild.h:763
Definition: GuildPackets.h:648
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
bool IsMember(ObjectGuid guid) const
Definition: Guild.cpp:2719
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
Definition: Group.h:191

+ Here is the call graph for this function:

void Guild::HandleGuildRequestChallengeUpdate ( WorldSession session)
Todo:
current count
1993 {
1995 
1996  for (int i = 0; i < GUILD_CHALLENGES_TYPES; ++i)
1997  updatePacket.CurrentCount[i] = int32(0);
1998 
1999  for (int i = 0; i < GUILD_CHALLENGES_TYPES; ++i)
2000  updatePacket.MaxCount[i] = int32(GuildChallengesMaxCount[i]);
2001 
2002  for (int i = 0; i < GUILD_CHALLENGES_TYPES; ++i)
2003  updatePacket.MaxLevelGold[i] = int32(GuildChallengeMaxLevelGoldReward[i]);
2004 
2005  for (int i = 0; i < GUILD_CHALLENGES_TYPES; ++i)
2006  updatePacket.Gold[i] = int32(GuildChallengeGoldReward[i]);
2007 
2008  session->SendPacket(updatePacket.Write());
2009 }
const uint32 GuildChallengeMaxLevelGoldReward[GUILD_CHALLENGES_TYPES]
Definition: Guild.h:260
const uint32 GuildChallengesMaxCount[GUILD_CHALLENGES_TYPES]
Definition: Guild.h:261
int32 MaxLevelGold[GUILD_CHALLENGES_TYPES]
Definition: GuildPackets.h:982
Definition: GuildPackets.h:972
int32 MaxCount[GUILD_CHALLENGES_TYPES]
Definition: GuildPackets.h:980
WorldPacket const * Write() override
Definition: GuildPackets.cpp:784
int32_t int32
Definition: Define.h:146
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
#define GUILD_CHALLENGES_TYPES
Definition: Guild.h:257
int32 CurrentCount[GUILD_CHALLENGES_TYPES]
Definition: GuildPackets.h:979
const uint32 GuildChallengeGoldReward[GUILD_CHALLENGES_TYPES]
Definition: Guild.h:259
int32 Gold[GUILD_CHALLENGES_TYPES]
Definition: GuildPackets.h:981

+ Here is the call graph for this function:

void Guild::HandleInviteMember ( WorldSession session,
std::string const name 
)
1596 {
1597  Player* pInvitee = ObjectAccessor::FindPlayerByName(name);
1598  if (!pInvitee)
1599  {
1601  return;
1602  }
1603 
1604  Player* player = session->GetPlayer();
1605  // Do not show invitations from ignored players
1606  if (pInvitee->GetSocial()->HasIgnore(player->GetGUID()))
1607  return;
1608 
1609  if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && pInvitee->GetTeam() != player->GetTeam())
1610  {
1612  return;
1613  }
1614 
1615  // Invited player cannot be in another guild
1616  if (pInvitee->GetGuildId())
1617  {
1619  return;
1620  }
1621 
1622  // Invited player cannot be invited
1623  if (pInvitee->GetGuildIdInvited())
1624  {
1626  return;
1627  }
1628 
1629  // Inviting player must have rights to invite
1630  if (!_HasRankRight(player, GR_RIGHT_INVITE))
1631  {
1633  return;
1634  }
1635 
1637 
1638  TC_LOG_DEBUG("guild", "Player %s invited %s to join his Guild", player->GetName().c_str(), name.c_str());
1639 
1640  pInvitee->SetGuildIdInvited(m_id);
1641  _LogEvent(GUILD_EVENT_LOG_INVITE_PLAYER, player->GetGUID().GetCounter(), pInvitee->GetGUID().GetCounter());
1642 
1644 
1646  invite.GuildVirtualRealmAddress = GetVirtualRealmAddress();
1647  invite.GuildGUID = GetGUID();
1648 
1649  invite.EmblemStyle = uint32(m_emblemInfo.GetStyle());
1650  invite.EmblemColor = uint32(m_emblemInfo.GetColor());
1651  invite.BorderStyle = uint32(m_emblemInfo.GetBorderStyle());
1652  invite.BorderColor = uint32(m_emblemInfo.GetBorderColor());
1653  invite.Background = uint32(m_emblemInfo.GetBackgroundColor());
1654  invite.Level = int32(GetLevel());
1655 
1656  invite.InviterName = player->GetName();
1657  invite.GuildName = GetName();
1658 
1659  if (Guild* oldGuild = pInvitee->GetGuild())
1660  {
1661  invite.OldGuildGUID = oldGuild->GetGUID();
1662  invite.OldGuildName = oldGuild->GetName();
1663  invite.OldGuildVirtualRealmAddress = GetVirtualRealmAddress();
1664  }
1665 
1666  pInvitee->GetSession()->SendPacket(invite.Write());
1667  TC_LOG_DEBUG("guild", "SMSG_GUILD_INVITE [%s]", pInvitee->GetName().c_str());
1668 }
Definition: Guild.h:82
static void SendCommandResult(WorldSession *session, GuildCommandType type, GuildCommandError errCode, std::string const &param="")
Definition: Guild.cpp:53
EmblemInfo m_emblemInfo
Definition: Guild.h:890
Definition: Guild.h:127
Definition: Guild.h:105
std::string const & GetName() const
Definition: Guild.h:766
Definition: Guild.h:129
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sWorld
Definition: World.h:887
Definition: GuildPackets.h:206
Definition: Guild.h:137
uint32 InviterVirtualRealmAddress
Definition: GuildPackets.h:223
Definition: Guild.h:205
uint32 GetBorderColor() const
Definition: Guild.h:277
uint32 GetBorderStyle() const
Definition: Guild.h:276
Definition: Guild.h:133
uint8 GetLevel() const
Definition: Guild.h:872
Definition: Guild.h:136
uint32 GetColor() const
Definition: Guild.h:275
bool _HasRankRight(Player const *player, uint32 right) const
Definition: Guild.h:910
uint32 GetStyle() const
Definition: Guild.h:274
ObjectGuid GetGUID() const
Definition: Guild.h:764
TC_GAME_API Player * FindPlayerByName(std::string const &name)
Definition: ObjectAccessor.cpp:220
void _LogEvent(GuildEventLogTypes eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2=UI64LIT(0), uint8 newRank=0)
Definition: Guild.cpp:3013
ObjectGuid::LowType m_id
Definition: Guild.h:883
int32_t int32
Definition: g3dmath.h:167
uint32 GetVirtualRealmAddress()
Definition: World.cpp:3487
uint32_t uint32
Definition: g3dmath.h:168
uint32 GetBackgroundColor() const
Definition: Guild.h:278
Definition: Guild.h:320
Definition: Guild.h:124

+ Here is the call graph for this function:

void Guild::HandleLeaveMember ( WorldSession session)
1681 {
1682  Player* player = session->GetPlayer();
1683  bool disband = false;
1684 
1685  // If leader is leaving
1686  if (_IsLeader(player))
1687  {
1688  if (m_members.size() > 1)
1689  // Leader cannot leave if he is not the last member
1691  else if (GetLevel() >= sWorld->getIntConfig(CONFIG_GUILD_UNDELETABLE_LEVEL))
1693  else
1694  {
1695  // Guild is disbanded if leader leaves.
1696  Disband();
1697  disband = true;
1698  }
1699  }
1700  else
1701  {
1702  _LogEvent(GUILD_EVENT_LOG_LEAVE_GUILD, player->GetGUID().GetCounter());
1703  SendEventPlayerLeft(GetMember(player->GetGUID()));
1704 
1705  DeleteMember(player->GetGUID(), false, false);
1706 
1708  }
1709 
1710  sCalendarMgr->RemovePlayerGuildEventsAndSignups(player->GetGUID(), GetId());
1711 
1712  if (disband)
1713  delete this;
1714 }
static void SendCommandResult(WorldSession *session, GuildCommandType type, GuildCommandError errCode, std::string const &param="")
Definition: Guild.cpp:53
bool _IsLeader(Player *player) const
Definition: Guild.cpp:2850
#define sCalendarMgr
Definition: CalendarMgr.h:334
const Member * GetMember(ObjectGuid guid) const
Definition: Guild.h:924
Definition: Guild.h:132
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sWorld
Definition: World.h:887
void DeleteMember(ObjectGuid guid, bool isDisbanding=false, bool isKicked=false, bool canDeleteGuild=false)
Definition: Guild.cpp:2646
void Disband()
Definition: Guild.cpp:1140
uint8 GetLevel() const
Definition: Guild.h:872
Definition: World.h:357
Definition: Guild.h:153
Members m_members
Definition: Guild.h:895
ObjectGuid::LowType GetId() const
Definition: Guild.h:763
std::string m_name
Definition: Guild.h:884
void _LogEvent(GuildEventLogTypes eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2=UI64LIT(0), uint8 newRank=0)
Definition: Guild.cpp:3013
void SendEventPlayerLeft(Member *leaver, Member *remover=nullptr, bool isRemoved=false)
Definition: Guild.cpp:2216
Definition: Guild.h:210
Definition: Guild.h:106
Definition: Guild.h:124

+ Here is the call graph for this function:

void Guild::HandleMemberDepositMoney ( WorldSession session,
uint64  amount,
bool  cashFlow = false 
)
1878 {
1879  Player* player = session->GetPlayer();
1880 
1881  // Call script after validation and before money transfer.
1882  sScriptMgr->OnGuildMemberDepositMoney(this, player, amount);
1883 
1885  _ModifyBankMoney(trans, amount, true);
1886  if (!cashFlow)
1887  {
1888  player->ModifyMoney(-int64(amount));
1889  player->SaveGoldToDB(trans);
1890  }
1891 
1892  _LogBankEvent(trans, cashFlow ? GUILD_BANK_LOG_CASH_FLOW_DEPOSIT : GUILD_BANK_LOG_DEPOSIT_MONEY, uint8(0), player->GetGUID().GetCounter(), amount);
1894 
1896 
1897  if (player->GetSession()->HasPermission(rbac::RBAC_PERM_LOG_GM_TRADE))
1898  {
1899  sLog->outCommand(player->GetSession()->GetAccountId(),
1900  "GM %s (Account: %u) deposit money (Amount: " UI64FMTD ") to guild bank (Guild ID " UI64FMTD ")",
1901  player->GetName().c_str(), player->GetSession()->GetAccountId(), amount, m_id);
1902  }
1903 }
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
Definition: Guild.h:200
#define sLog
Definition: Log.h:154
Player * GetPlayer() const
Definition: WorldSession.h:927
bool _ModifyBankMoney(SQLTransaction &trans, uint64 amount, bool add)
Definition: Guild.cpp:2870
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
#define UI64FMTD
Definition: Define.h:137
int64_t int64
Definition: g3dmath.h:169
uint8_t uint8
Definition: g3dmath.h:164
ObjectGuid::LowType m_id
Definition: Guild.h:883
Definition: RBAC.h:63
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define sScriptMgr
Definition: ScriptMgr.h:837
Definition: Guild.h:194
void _LogBankEvent(SQLTransaction &trans, GuildBankEventLogTypes eventType, uint8 tabId, ObjectGuid::LowType playerGuid, uint64 itemOrMoney, uint16 itemStackCount=0, uint8 destTabId=0)
Definition: Guild.cpp:3023
void SendEventBankMoneyChanged()
Definition: Guild.cpp:2174
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

void Guild::HandleMemberLogout ( WorldSession session)
1949 {
1950  Player* player = session->GetPlayer();
1951  if (Member* member = GetMember(player->GetGUID()))
1952  {
1953  member->SetStats(player);
1954  member->UpdateLogoutTime();
1955  member->ResetFlags();
1956  }
1957 
1958  SendEventPresenceChanged(session, false, true);
1959  SaveToDB();
1960 }
const Member * GetMember(ObjectGuid guid) const
Definition: Guild.h:924
Player * GetPlayer() const
Definition: WorldSession.h:927
void SendEventPresenceChanged(WorldSession *session, bool loggedOn, bool broadcast=false)
Definition: Guild.cpp:2234
void SaveToDB()
Definition: Guild.cpp:1195

+ Here is the call graph for this function:

bool Guild::HandleMemberWithdrawMoney ( WorldSession session,
uint64  amount,
bool  repair = false 
)
1906 {
1907  // clamp amount to MAX_MONEY_AMOUNT, Players can't hold more than that anyway
1908  amount = std::min(amount, uint64(MAX_MONEY_AMOUNT));
1909 
1910  if (m_bankMoney < amount) // Not enough money in bank
1911  return false;
1912 
1913  Player* player = session->GetPlayer();
1914 
1915  Member* member = GetMember(player->GetGUID());
1916  if (!member)
1917  return false;
1918 
1919  if (uint64(_GetMemberRemainingMoney(member)) < amount) // Check if we have enough slot/money today
1920  return false;
1921 
1922  // Call script after validation and before money transfer.
1923  sScriptMgr->OnGuildMemberWitdrawMoney(this, player, amount, repair);
1924 
1926  // Add money to player (if required)
1927  if (!repair)
1928  {
1929  if (!player->ModifyMoney(amount))
1930  return false;
1931 
1932  player->SaveGoldToDB(trans);
1933  }
1934 
1935  // Update remaining money amount
1936  member->UpdateBankWithdrawValue(trans, GUILD_BANK_MAX_TABS, amount);
1937  // Remove money from bank
1938  _ModifyBankMoney(trans, amount, false);
1939 
1940  // Log guild bank event
1941  _LogBankEvent(trans, repair ? GUILD_BANK_LOG_REPAIR_MONEY : GUILD_BANK_LOG_WITHDRAW_MONEY, uint8(0), player->GetGUID().GetCounter(), amount);
1943 
1945  return true;
1946 }
uint64 const MAX_MONEY_AMOUNT
Definition: Player.cpp:130
const Member * GetMember(ObjectGuid guid) const
Definition: Guild.h:924
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
Definition: Guild.h:196
uint64_t uint64
Definition: g3dmath.h:170
Player * GetPlayer() const
Definition: WorldSession.h:927
bool _ModifyBankMoney(SQLTransaction &trans, uint64 amount, bool add)
Definition: Guild.cpp:2870
Definition: Guild.h:44
Definition: Guild.h:195
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
T min(const T &x, const T &y)
Definition: g3dmath.h:305
uint8_t uint8
Definition: g3dmath.h:164
int32 _GetMemberRemainingMoney(Member const *member) const
Definition: Guild.cpp:2971
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define sScriptMgr
Definition: ScriptMgr.h:837
uint64 m_bankMoney
Definition: Guild.h:892
void _LogBankEvent(SQLTransaction &trans, GuildBankEventLogTypes eventType, uint8 tabId, ObjectGuid::LowType playerGuid, uint64 itemOrMoney, uint16 itemStackCount=0, uint8 destTabId=0)
Definition: Guild.cpp:3023
void SendEventBankMoneyChanged()
Definition: Guild.cpp:2174
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

void Guild::HandleNewsSetSticky ( WorldSession session,
uint32  newsId,
bool  sticky 
)
3393 {
3394  GuildLog* logs = m_newsLog->GetGuildLog();
3395  GuildLog::iterator itr = logs->begin();
3396  while (itr != logs->end() && (*itr)->GetGUID() != newsId)
3397  ++itr;
3398 
3399  if (itr == logs->end())
3400  {
3401  TC_LOG_DEBUG("guild", "HandleNewsSetSticky: [%s] requested unknown newsId %u - Sticky: %u",
3402  session->GetPlayerInfo().c_str(), newsId, sticky);
3403  return;
3404  }
3405 
3406  NewsLogEntry* news = (NewsLogEntry*)(*itr);
3407  news->SetSticky(sticky);
3408 
3409  TC_LOG_DEBUG("guild", "HandleNewsSetSticky: [%s] changed newsId %u sticky to %u",
3410  session->GetPlayerInfo().c_str(), newsId, sticky);
3411 
3412  WorldPackets::Guild::GuildNews newsPacket;
3413  newsPacket.NewsEvents.reserve(1);
3414  news->WritePacket(newsPacket);
3415  session->SendPacket(newsPacket.Write());
3416 }
Definition: GuildPackets.h:932
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
GuildLog * GetGuildLog()
Definition: Guild.h:563
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
std::list< LogEntry * > GuildLog
Definition: Guild.h:547
std::vector< GuildNewsEvent > NewsEvents
Definition: GuildPackets.h:939
LogHolder * m_newsLog
Definition: Guild.h:901

+ Here is the call graph for this function:

void Guild::HandleRemoveMember ( WorldSession session,
ObjectGuid  guid 
)
1717 {
1718  Player* player = session->GetPlayer();
1719 
1720  // Player must have rights to remove members
1721  if (!_HasRankRight(player, GR_RIGHT_REMOVE))
1723  else if (Member* member = GetMember(guid))
1724  {
1725  std::string name = member->GetName();
1726 
1727  // Guild masters cannot be removed
1728  if (member->IsRank(GR_GUILDMASTER))
1730  // Do not allow to remove player with the same rank or higher
1731  else
1732  {
1733  Member* memberMe = GetMember(player->GetGUID());
1734  if (!memberMe || member->IsRankNotLower(memberMe->GetRankId()))
1736  else
1737  {
1738  _LogEvent(GUILD_EVENT_LOG_UNINVITE_PLAYER, player->GetGUID().GetCounter(), guid.GetCounter());
1739  SendEventPlayerLeft(member, memberMe, true);
1740 
1741  // After call to DeleteMember pointer to member becomes invalid
1742  DeleteMember(guid, false, true);
1743 
1745  }
1746  }
1747  }
1748 }
Definition: Guild.h:66
static void SendCommandResult(WorldSession *session, GuildCommandType type, GuildCommandError errCode, std::string const &param="")
Definition: Guild.cpp:53
const Member * GetMember(ObjectGuid guid) const
Definition: Guild.h:924
Definition: Guild.h:132
Player * GetPlayer() const
Definition: WorldSession.h:927
void DeleteMember(ObjectGuid guid, bool isDisbanding=false, bool isKicked=false, bool canDeleteGuild=false)
Definition: Guild.cpp:2646
Definition: Guild.h:133
Definition: Guild.h:138
bool _HasRankRight(Player const *player, uint32 right) const
Definition: Guild.h:910
void _LogEvent(GuildEventLogTypes eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2=UI64LIT(0), uint8 newRank=0)
Definition: Guild.cpp:3013
Definition: Guild.h:110
Definition: Guild.h:209
void SendEventPlayerLeft(Member *leaver, Member *remover=nullptr, bool isRemoved=false)
Definition: Guild.cpp:2216
Definition: Guild.h:124
Definition: Guild.h:83
LowType GetCounter() const
Definition: ObjectGuid.h:221

+ Here is the call graph for this function:

void Guild::HandleRemoveRank ( WorldSession session,
uint8  rankId 
)
1854 {
1855  // Cannot remove rank if total count is minimum allowed by the client or is not leader
1856  if (_GetRanksSize() <= GUILD_RANKS_MIN_COUNT || rankId >= _GetRanksSize() || !_IsLeader(session->GetPlayer()))
1857  return;
1858 
1859  // Delete bank rights for rank
1861  stmt->setUInt64(0, m_id);
1862  stmt->setUInt8(1, rankId);
1863  CharacterDatabase.Execute(stmt);
1864 
1865  // Delete rank
1867  stmt->setUInt64(0, m_id);
1868  stmt->setUInt8(1, rankId);
1869  CharacterDatabase.Execute(stmt);
1870 
1871  m_ranks.erase(m_ranks.begin() + rankId);
1872 
1874  BroadcastPacket(eventPacket.Write());
1875 }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
bool _IsLeader(Player *player) const
Definition: Guild.cpp:2850
WorldPacket const * Write() override
Definition: GuildPackets.h:280
Definition: CharacterDatabase.h:176
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
Player * GetPlayer() const
Definition: WorldSession.h:927
void BroadcastPacket(WorldPacket const *packet) const
Definition: Guild.cpp:2520
Definition: PreparedStatement.h:74
Definition: Guild.h:47
uint8 _GetRanksSize() const
Definition: Guild.h:907
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Ranks m_ranks
Definition: Guild.h:894
ObjectGuid::LowType m_id
Definition: Guild.h:883
Definition: CharacterDatabase.h:166
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: GuildPackets.h:275

+ Here is the call graph for this function:

void Guild::HandleRoster ( WorldSession session)
1276 {
1278 
1280  roster.CreateDate = uint32(m_createdDate);
1281  roster.GuildFlags = 0;
1282 
1283  roster.MemberData.reserve(m_members.size());
1284 
1285  for (auto itr : m_members)
1286  {
1287  Member* member = itr.second;
1288 
1290 
1291  memberData.Guid = member->GetGUID();
1292  memberData.RankID = int32(member->GetRankId());
1293  memberData.AreaID = int32(member->GetZoneId());
1294  memberData.PersonalAchievementPoints = int32(member->GetAchievementPoints());
1295  memberData.GuildReputation = int32(member->GetTotalReputation());
1296  memberData.LastSave = float(member->IsOnline() ? 0.0f : float(::time(NULL) - member->GetLogoutTime()) / DAY);
1297 
1298  //GuildRosterProfessionData
1299 
1301  memberData.Status = member->GetFlags();
1302  memberData.Level = member->GetLevel();
1303  memberData.ClassID = member->GetClass();
1304  memberData.Gender = member->GetGender();
1305 
1306  memberData.Authenticated = false;
1307  memberData.SorEligible = false;
1308 
1309  memberData.Name = member->GetName();
1310  memberData.Note = member->GetPublicNote();
1311  memberData.OfficerNote = member->GetOfficerNote();
1312 
1313  roster.MemberData.push_back(memberData);
1314  }
1315 
1316  roster.WelcomeText = m_motd;
1317  roster.InfoText = m_info;
1318 
1319  TC_LOG_DEBUG("guild", "SMSG_GUILD_ROSTER [%s]", session->GetPlayerInfo().c_str());
1320  session->SendPacket(roster.Write());
1321 }
std::string Name
Definition: GuildPackets.h:110
std::string InfoText
Definition: GuildPackets.h:132
std::string WelcomeText
Definition: GuildPackets.h:131
bool SorEligible
Definition: GuildPackets.h:119
int32 GuildFlags
Definition: GuildPackets.h:135
int32 RankID
Definition: GuildPackets.h:104
uint32 m_accountsNumber
Definition: Guild.h:891
Definition: GuildPackets.h:99
arena_t NULL
Definition: jemalloc_internal.h:624
time_t m_createdDate
Definition: Guild.h:888
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint8 Status
Definition: GuildPackets.h:114
std::string OfficerNote
Definition: GuildPackets.h:113
int32 GuildReputation
Definition: GuildPackets.h:107
int32 NumAccounts
Definition: GuildPackets.h:134
uint32 VirtualRealmAddress
Definition: GuildPackets.h:111
std::string m_motd
Definition: Guild.h:886
std::vector< GuildRosterMemberData > MemberData
Definition: GuildPackets.h:130
Definition: Common.h:99
uint8 Level
Definition: GuildPackets.h:115
int32 PersonalAchievementPoints
Definition: GuildPackets.h:106
float LastSave
Definition: GuildPackets.h:109
Members m_members
Definition: Guild.h:895
ObjectGuid Guid
Definition: GuildPackets.h:101
Definition: GuildPackets.h:123
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
WorldPacket const * Write() override
Definition: GuildPackets.cpp:66
uint8 ClassID
Definition: GuildPackets.h:116
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
uint8 Gender
Definition: GuildPackets.h:117
int32_t int32
Definition: g3dmath.h:167
uint32 GetVirtualRealmAddress()
Definition: World.cpp:3487
uint32_t uint32
Definition: g3dmath.h:168
std::string Note
Definition: GuildPackets.h:112
uint32 CreateDate
Definition: GuildPackets.h:133
int32 AreaID
Definition: GuildPackets.h:105
std::string m_info
Definition: Guild.h:887
bool Authenticated
Definition: GuildPackets.h:118

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Guild::HandleSetAchievementTracking ( WorldSession session,
std::set< uint32 > const achievementIds 
)
1385 {
1386  Player* player = session->GetPlayer();
1387 
1388  if (Member* member = GetMember(player->GetGUID()))
1389  {
1390  std::set<uint32> criteriaIds;
1391 
1392  for (uint32 achievementId : achievementIds)
1393  {
1394  if (AchievementEntry const* achievement = sAchievementMgr->GetAchievement(achievementId))
1395  {
1396  if (AchievementCriteriaTree const* tree = sAchievementMgr->GetAchievementCriteriaTree(achievement->CriteriaTree))
1397  {
1398  sAchievementMgr->WalkCriteriaTree(tree, [&criteriaIds](AchievementCriteriaTree const* node)
1399  {
1400  if (node->Criteria)
1401  criteriaIds.insert(node->Criteria->ID);
1402  });
1403  }
1404  }
1405  }
1406 
1407  member->SetTrackedCriteriaIds(criteriaIds);
1408  m_achievementMgr.SendAllTrackedCriterias(player, member->GetTrackedCriteriaIds());
1409  }
1410 }
AchievementMgr< Guild > m_achievementMgr
Definition: Guild.h:902
uint32 ID
Definition: AchievementMgr.h:53
const Member * GetMember(ObjectGuid guid) const
Definition: Guild.h:924
AchievementCriteria const * Criteria
Definition: AchievementMgr.h:67
Definition: AchievementMgr.h:62
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: DB2Structure.h:27
uint32_t uint32
Definition: Define.h:150
#define sAchievementMgr
Definition: AchievementMgr.h:501
void SendAllTrackedCriterias(Player *receiver, std::set< uint32 > const &trackedCriterias) const
Definition: AchievementMgr.cpp:919

+ Here is the call graph for this function:

void Guild::HandleSetBankTabInfo ( WorldSession session,
uint8  tabId,
std::string const name,
std::string const icon 
)
1495 {
1496  BankTab* tab = GetBankTab(tabId);
1497  if (!tab)
1498  {
1499  TC_LOG_ERROR("guild", "Guild::HandleSetBankTabInfo: Player %s trying to change bank tab info from unexisting tab %d.",
1500  session->GetPlayerInfo().c_str(), tabId);
1501  return;
1502  }
1503 
1504  tab->SetInfo(name, icon);
1505 
1507  packet.Tab = tabId;
1508  packet.Name = name;
1509  packet.Icon = icon;
1510  BroadcastPacket(packet.Write());
1511 }
Definition: GuildPackets.h:368
std::string Name
Definition: GuildPackets.h:376
BankTab * GetBankTab(uint8 tabId)
Definition: Guild.h:921
void BroadcastPacket(WorldPacket const *packet) const
Definition: Guild.cpp:2520
std::string Icon
Definition: GuildPackets.h:375
WorldPacket const * Write() override
Definition: GuildPackets.cpp:341
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
int32 Tab
Definition: GuildPackets.h:377

+ Here is the call graph for this function:

void Guild::HandleSetEmblem ( WorldSession session,
const EmblemInfo emblemInfo 
)
1455 {
1456  Player* player = session->GetPlayer();
1457  if (!_IsLeader(player))
1458  SendSaveEmblemResult(session, ERR_GUILDEMBLEM_NOTGUILDMASTER); // "Only guild leaders can create emblems."
1459  else if (!player->HasEnoughMoney(uint64(EMBLEM_PRICE)))
1460  SendSaveEmblemResult(session, ERR_GUILDEMBLEM_NOTENOUGHMONEY); // "You can't afford to do that."
1461  else
1462  {
1463  player->ModifyMoney(-int64(EMBLEM_PRICE));
1464 
1465  m_emblemInfo = emblemInfo;
1467 
1468  SendSaveEmblemResult(session, ERR_GUILDEMBLEM_SUCCESS); // "Guild Emblem saved."
1469 
1470  SendQueryResponse(session);
1471  }
1472 }
Definition: Guild.h:219
Definition: Guild.h:218
bool _IsLeader(Player *player) const
Definition: Guild.cpp:2850
EmblemInfo m_emblemInfo
Definition: Guild.h:890
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Guild.h:215
static void SendSaveEmblemResult(WorldSession *session, GuildEmblemError errCode)
Definition: Guild.cpp:65
void SaveToDB(ObjectGuid::LowType guildId) const
Definition: Guild.cpp:701
uint64_t uint64
Definition: Define.h:149
#define EMBLEM_PRICE
Definition: Guild.cpp:37
int64_t int64
Definition: g3dmath.h:169
ObjectGuid::LowType m_id
Definition: Guild.h:883
void SendQueryResponse(WorldSession *session)
Definition: Guild.cpp:1323

+ Here is the call graph for this function:

void Guild::HandleSetInfo ( WorldSession session,
std::string const info 
)
1436 {
1437  if (m_info == info)
1438  return;
1439 
1440  // Player must have rights to set guild's info
1442  {
1443  m_info = info;
1444 
1445  sScriptMgr->OnGuildInfoChanged(this, info);
1446 
1448  stmt->setString(0, info);
1449  stmt->setUInt64(1, m_id);
1450  CharacterDatabase.Execute(stmt);
1451  }
1452 }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Definition: CharacterDatabase.h:187
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: PreparedStatement.h:74
Definition: Guild.h:94
bool _HasRankRight(Player const *player, uint32 right) const
Definition: Guild.h:910
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
ObjectGuid::LowType m_id
Definition: Guild.h:883
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define sScriptMgr
Definition: ScriptMgr.h:837
std::string m_info
Definition: Guild.h:887

+ Here is the call graph for this func