mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-02-17 07:29:20 +01:00
Core: ported headers cleanup from master branch
This commit is contained in:
@@ -16,20 +16,25 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "Guild.h"
|
||||
#include "AccountMgr.h"
|
||||
#include "Bag.h"
|
||||
#include "CalendarMgr.h"
|
||||
#include "CharacterCache.h"
|
||||
#include "Chat.h"
|
||||
#include "Config.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "Guild.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "Language.h"
|
||||
#include "Log.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Opcodes.h"
|
||||
#include "Player.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "SocialMgr.h"
|
||||
#include "Opcodes.h"
|
||||
|
||||
#include "World.h"
|
||||
#include "WorldSession.h"
|
||||
|
||||
size_t const MAX_GUILD_BANK_TAB_TEXT_LEN = 500;
|
||||
|
||||
@@ -384,6 +389,11 @@ void Guild::RankInfo::SetBankTabSlotsAndRights(GuildBankRightsAndSlots rightsAnd
|
||||
}
|
||||
|
||||
// BankTab
|
||||
Guild::BankTab::BankTab(ObjectGuid::LowType guildId, uint8 tabId) : m_guildId(guildId), m_tabId(tabId)
|
||||
{
|
||||
memset(m_items, 0, GUILD_BANK_MAX_SLOTS * sizeof(Item*));
|
||||
}
|
||||
|
||||
void Guild::BankTab::LoadFromDB(Field* fields)
|
||||
{
|
||||
m_name = fields[2].GetString();
|
||||
@@ -505,6 +515,12 @@ bool Guild::BankTab::WriteSlotPacket(WorldPacket& data, uint8 slotId, bool ignor
|
||||
return true;
|
||||
}
|
||||
|
||||
void Guild::BankTab::WriteInfoPacket(WorldPacket& data) const
|
||||
{
|
||||
data << m_name;
|
||||
data << m_icon;
|
||||
}
|
||||
|
||||
void Guild::BankTab::SetInfo(std::string const& name, std::string const& icon)
|
||||
{
|
||||
if (m_name == name && m_icon == icon)
|
||||
@@ -589,6 +605,20 @@ void Guild::BankTab::SendText(Guild const* guild, WorldSession* session) const
|
||||
}
|
||||
|
||||
// Member
|
||||
Guild::Member::Member(ObjectGuid::LowType guildId, ObjectGuid guid, uint8 rankId) :
|
||||
m_guildId(guildId),
|
||||
m_guid(guid),
|
||||
m_zoneId(0),
|
||||
m_level(0),
|
||||
m_class(0),
|
||||
m_flags(GUILDMEMBER_STATUS_NONE),
|
||||
m_logoutTime(::time(nullptr)),
|
||||
m_accountId(0),
|
||||
m_rankId(rankId)
|
||||
{
|
||||
memset(m_bankWithdraw, 0, (GUILD_BANK_MAX_TABS + 1) * sizeof(int32));
|
||||
}
|
||||
|
||||
void Guild::Member::SetStats(Player* player)
|
||||
{
|
||||
m_name = player->GetName();
|
||||
@@ -728,6 +758,16 @@ void Guild::Member::WritePacket(WorldPacket& data, bool sendOfficerNote) const
|
||||
data << "";
|
||||
}
|
||||
|
||||
Player* Guild::Member::FindPlayer() const
|
||||
{
|
||||
return ObjectAccessor::FindPlayer(m_guid);
|
||||
}
|
||||
|
||||
Player* Guild::Member::FindConnectedPlayer() const
|
||||
{
|
||||
return ObjectAccessor::FindConnectedPlayer(m_guid);
|
||||
}
|
||||
|
||||
// Decreases amount of money/slots left for today.
|
||||
// If (tabId == GUILD_BANK_MAX_TABS) decrease money amount.
|
||||
// Otherwise decrease remaining items amount for specified tab.
|
||||
@@ -801,6 +841,15 @@ void EmblemInfo::SaveToDB(ObjectGuid::LowType guildId) const
|
||||
}
|
||||
|
||||
// MoveItemData
|
||||
Guild::MoveItemData::MoveItemData(Guild* guild, Player* player, uint8 container, uint8 slotId) : m_pGuild(guild), m_pPlayer(player),
|
||||
m_container(container), m_slotId(slotId), m_pItem(nullptr), m_pClonedItem(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
Guild::MoveItemData::~MoveItemData()
|
||||
{
|
||||
}
|
||||
|
||||
bool Guild::MoveItemData::CheckItem(uint32& splitedAmount)
|
||||
{
|
||||
ASSERT(m_pItem);
|
||||
@@ -1392,7 +1441,7 @@ void Guild::HandleSetInfo(WorldSession* session, std::string const& info)
|
||||
}
|
||||
}
|
||||
|
||||
void Guild::HandleSetEmblem(WorldSession* session, const EmblemInfo& emblemInfo)
|
||||
void Guild::HandleSetEmblem(WorldSession* session, EmblemInfo const& emblemInfo)
|
||||
{
|
||||
Player* player = session->GetPlayer();
|
||||
if (!_IsLeader(player))
|
||||
@@ -1463,7 +1512,7 @@ void Guild::HandleSetMemberNote(WorldSession* session, std::string const& name,
|
||||
}
|
||||
}
|
||||
|
||||
void Guild::HandleSetRankInfo(WorldSession* session, uint8 rankId, std::string const& name, uint32 rights, uint32 moneyPerDay, const GuildBankRightsAndSlotsVec& rightsAndSlots)
|
||||
void Guild::HandleSetRankInfo(WorldSession* session, uint8 rankId, std::string const& name, uint32 rights, uint32 moneyPerDay, GuildBankRightsAndSlotsVec const& rightsAndSlots)
|
||||
{
|
||||
// Only leader can modify ranks
|
||||
if (!_IsLeader(session->GetPlayer()))
|
||||
@@ -1561,7 +1610,7 @@ void Guild::HandleInviteMember(WorldSession* session, std::string const& name)
|
||||
WorldPacket data(SMSG_GUILD_INVITE, 8 + 10); // Guess size
|
||||
data << player->GetName();
|
||||
data << m_name;
|
||||
pInvitee->GetSession()->SendPacket(&data);
|
||||
pInvitee->SendDirectMessage(&data);
|
||||
TC_LOG_DEBUG("guild", "SMSG_GUILD_INVITE [%s]", pInvitee->GetName().c_str());
|
||||
}
|
||||
|
||||
@@ -1857,7 +1906,7 @@ void Guild::SendBankLog(WorldSession* session, uint8 tabId) const
|
||||
// GUILD_BANK_MAX_TABS send by client for money log
|
||||
if (tabId < _GetPurchasedTabsSize() || tabId == GUILD_BANK_MAX_TABS)
|
||||
{
|
||||
const LogHolder* pLog = m_bankEventLog[tabId];
|
||||
LogHolder const* pLog = m_bankEventLog[tabId];
|
||||
WorldPacket data(MSG_GUILD_BANK_LOG_QUERY, pLog->GetSize() * (4 * 4 + 1) + 1 + 1);
|
||||
data << uint8(tabId);
|
||||
pLog->WritePacket(data);
|
||||
@@ -2164,7 +2213,7 @@ void Guild::BroadcastToGuild(WorldSession* session, bool officerOnly, std::strin
|
||||
if (Player* player = itr->second->FindConnectedPlayer())
|
||||
if (player->GetSession() && _HasRankRight(player, officerOnly ? GR_RIGHT_OFFCHATLISTEN : GR_RIGHT_GCHATLISTEN) &&
|
||||
!player->GetSocial()->HasIgnore(session->GetPlayer()->GetGUID()))
|
||||
player->GetSession()->SendPacket(&data);
|
||||
player->SendDirectMessage(&data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2173,14 +2222,14 @@ void Guild::BroadcastPacketToRank(WorldPacket* packet, uint8 rankId) const
|
||||
for (auto itr = m_members.begin(); itr != m_members.end(); ++itr)
|
||||
if (itr->second->IsRank(rankId))
|
||||
if (Player* player = itr->second->FindConnectedPlayer())
|
||||
player->GetSession()->SendPacket(packet);
|
||||
player->SendDirectMessage(packet);
|
||||
}
|
||||
|
||||
void Guild::BroadcastPacket(WorldPacket* packet) const
|
||||
{
|
||||
for (auto itr = m_members.begin(); itr != m_members.end(); ++itr)
|
||||
if (Player* player = itr->second->FindPlayer())
|
||||
player->GetSession()->SendPacket(packet);
|
||||
player->SendDirectMessage(packet);
|
||||
}
|
||||
|
||||
void Guild::MassInviteToEvent(WorldSession* session, uint32 minLevel, uint32 maxLevel, uint32 minRank)
|
||||
@@ -2406,6 +2455,21 @@ void Guild::SetBankTabText(uint8 tabId, std::string const& text)
|
||||
}
|
||||
}
|
||||
|
||||
bool Guild::_HasRankRight(Player* player, uint32 right) const
|
||||
{
|
||||
if (player)
|
||||
if (Member const* member = GetMember(player->GetGUID()))
|
||||
return (_GetRankRights(member->GetRankId()) & right) != GR_RIGHT_EMPTY;
|
||||
return false;
|
||||
}
|
||||
|
||||
void Guild::_DeleteMemberFromDB(SQLTransaction& trans, ObjectGuid::LowType lowguid)
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_MEMBER);
|
||||
stmt->setUInt32(0, lowguid);
|
||||
CharacterDatabase.ExecuteOrAppend(trans, stmt);
|
||||
}
|
||||
|
||||
// Private methods
|
||||
void Guild::_CreateLogHolders()
|
||||
{
|
||||
@@ -2499,7 +2563,7 @@ bool Guild::_IsLeader(Player* player) const
|
||||
{
|
||||
if (player->GetGUID() == m_leaderGuid)
|
||||
return true;
|
||||
if (const Member* member = GetMember(player->GetGUID()))
|
||||
if (Member const* member = GetMember(player->GetGUID()))
|
||||
return member->IsRank(GR_GUILDMASTER);
|
||||
return false;
|
||||
}
|
||||
@@ -2568,21 +2632,21 @@ void Guild::_SetRankBankTabRightsAndSlots(uint8 rankId, GuildBankRightsAndSlots
|
||||
|
||||
inline std::string Guild::_GetRankName(uint8 rankId) const
|
||||
{
|
||||
if (const RankInfo* rankInfo = GetRankInfo(rankId))
|
||||
if (RankInfo const* rankInfo = GetRankInfo(rankId))
|
||||
return rankInfo->GetName();
|
||||
return "<unknown>";
|
||||
}
|
||||
|
||||
inline uint32 Guild::_GetRankRights(uint8 rankId) const
|
||||
{
|
||||
if (const RankInfo* rankInfo = GetRankInfo(rankId))
|
||||
if (RankInfo const* rankInfo = GetRankInfo(rankId))
|
||||
return rankInfo->GetRights();
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline int32 Guild::_GetRankBankMoneyPerDay(uint8 rankId) const
|
||||
{
|
||||
if (const RankInfo* rankInfo = GetRankInfo(rankId))
|
||||
if (RankInfo const* rankInfo = GetRankInfo(rankId))
|
||||
return rankInfo->GetBankMoneyPerDay();
|
||||
return 0;
|
||||
}
|
||||
@@ -2590,14 +2654,14 @@ inline int32 Guild::_GetRankBankMoneyPerDay(uint8 rankId) const
|
||||
inline int32 Guild::_GetRankBankTabSlotsPerDay(uint8 rankId, uint8 tabId) const
|
||||
{
|
||||
if (tabId < _GetPurchasedTabsSize())
|
||||
if (const RankInfo* rankInfo = GetRankInfo(rankId))
|
||||
if (RankInfo const* rankInfo = GetRankInfo(rankId))
|
||||
return rankInfo->GetBankTabSlotsPerDay(tabId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline int8 Guild::_GetRankBankTabRights(uint8 rankId, uint8 tabId) const
|
||||
{
|
||||
if (const RankInfo* rankInfo = GetRankInfo(rankId))
|
||||
if (RankInfo const* rankInfo = GetRankInfo(rankId))
|
||||
return rankInfo->GetBankTabRights(tabId);
|
||||
return 0;
|
||||
}
|
||||
@@ -2650,7 +2714,7 @@ inline void Guild::_UpdateMemberWithdrawSlots(SQLTransaction& trans, ObjectGuid
|
||||
|
||||
inline bool Guild::_MemberHasTabRights(ObjectGuid guid, uint8 tabId, uint32 rights) const
|
||||
{
|
||||
if (const Member* member = GetMember(guid))
|
||||
if (Member const* member = GetMember(guid))
|
||||
{
|
||||
// Leader always has full rights
|
||||
if (member->IsRank(GR_GUILDMASTER) || m_leaderGuid == guid)
|
||||
@@ -2694,7 +2758,7 @@ void Guild::_LogBankEvent(SQLTransaction& trans, GuildBankEventLogTypes eventTyp
|
||||
|
||||
inline Item* Guild::_GetItem(uint8 tabId, uint8 slotId) const
|
||||
{
|
||||
if (const BankTab* tab = GetBankTab(tabId))
|
||||
if (BankTab const* tab = GetBankTab(tabId))
|
||||
return tab->GetItem(slotId);
|
||||
return nullptr;
|
||||
}
|
||||
@@ -2861,7 +2925,7 @@ void Guild::_SendBankContentUpdate(uint8 tabId, SlotIds slots) const
|
||||
_SendBankList(nullptr, tabId, false, &slots);
|
||||
}
|
||||
|
||||
void Guild::_BroadcastEvent(GuildEvents guildEvent, ObjectGuid guid, const char* param1, const char* param2, const char* param3) const
|
||||
void Guild::_BroadcastEvent(GuildEvents guildEvent, ObjectGuid guid, char const* param1, char const* param2, char const* param3) const
|
||||
{
|
||||
uint8 count = !param3 ? (!param2 ? (!param1 ? 0 : 1) : 2) : 3;
|
||||
|
||||
@@ -2936,7 +3000,7 @@ void Guild::_SendBankList(WorldSession* session /* = nullptr*/, uint8 tabId /*=
|
||||
|
||||
uint32 numSlots = _GetMemberRemainingSlots(itr->second, tabId);
|
||||
data.put<uint32>(rempos, numSlots);
|
||||
player->GetSession()->SendPacket(&data);
|
||||
player->SendDirectMessage(&data);
|
||||
TC_LOG_DEBUG("guild", "SMSG_GUILD_BANK_LIST [%s]: TabId: %u, FullSlots: %u, slots: %u"
|
||||
, player->GetName().c_str(), tabId, sendAllSlots, numSlots);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user