TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Guild::BankTab Class Reference

Public Member Functions

 BankTab (ObjectGuid::LowType guildId, uint8 tabId)
 
void LoadFromDB (Field *fields)
 
bool LoadItemFromDB (Field *fields)
 
void Delete (SQLTransaction &trans, bool removeItemsFromDB=false)
 
void WritePacket (WorldPacket &data) const
 
bool WriteSlotPacket (WorldPacket &data, uint8 slotId, bool ignoreEmpty=true) const
 
void WriteInfoPacket (WorldPacket &data) const
 
void SetInfo (std::string const &name, std::string const &icon)
 
void SetText (std::string const &text)
 
void SendText (Guild const *guild, WorldSession *session) const
 
std::string constGetName () const
 
std::string constGetIcon () const
 
std::string constGetText () const
 
ItemGetItem (uint8 slotId) const
 
bool SetItem (SQLTransaction &trans, uint8 slotId, Item *item)
 

Private Attributes

ObjectGuid::LowType m_guildId
 
uint8 m_tabId
 
Itemm_items [GUILD_BANK_MAX_SLOTS]
 
std::string m_name
 
std::string m_icon
 
std::string m_text
 

Constructor & Destructor Documentation

Guild::BankTab::BankTab ( ObjectGuid::LowType  guildId,
uint8  tabId 
)
inline
621  : m_guildId(guildId), m_tabId(tabId)
622  {
623  memset(m_items, 0, GUILD_BANK_MAX_SLOTS * sizeof(Item*));
624  }
ObjectGuid::LowType m_guildId
Definition: Guild.h:650
uint8 m_tabId
Definition: Guild.h:651
Definition: Item.h:259
Item * m_items[GUILD_BANK_MAX_SLOTS]
Definition: Guild.h:653
Definition: Guild.h:45

Member Function Documentation

void Guild::BankTab::Delete ( SQLTransaction trans,
bool  removeItemsFromDB = false 
)
409 {
410  for (uint8 slotId = 0; slotId < GUILD_BANK_MAX_SLOTS; ++slotId)
411  if (Item* pItem = m_items[slotId])
412  {
413  pItem->RemoveFromWorld();
414  if (removeItemsFromDB)
415  pItem->DeleteFromDB(trans);
416  delete pItem;
417  pItem = NULL;
418  }
419 }
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Item.h:259
Item * m_items[GUILD_BANK_MAX_SLOTS]
Definition: Guild.h:653
uint8_t uint8
Definition: Define.h:152
Definition: Guild.h:45
std::string const& Guild::BankTab::GetIcon ( ) const
inline
643 { return m_icon; }
std::string m_icon
Definition: Guild.h:655
Item* Guild::BankTab::GetItem ( uint8  slotId) const
inline
646 { return slotId < GUILD_BANK_MAX_SLOTS ? m_items[slotId] : NULL; }
arena_t NULL
Definition: jemalloc_internal.h:624
Item * m_items[GUILD_BANK_MAX_SLOTS]
Definition: Guild.h:653
Definition: Guild.h:45

+ Here is the caller graph for this function:

std::string const& Guild::BankTab::GetName ( ) const
inline
642 { return m_name; }
std::string m_name
Definition: Guild.h:654
std::string const& Guild::BankTab::GetText ( ) const
inline
644 { return m_text; }
std::string m_text
Definition: Guild.h:656
void Guild::BankTab::LoadFromDB ( Field fields)
363 {
364  m_name = fields[2].GetString();
365  m_icon = fields[3].GetString();
366  m_text = fields[4].GetString();
367 }
std::string m_text
Definition: Guild.h:656
std::string m_icon
Definition: Guild.h:655
std::string m_name
Definition: Guild.h:654
std::string GetString() const
Definition: Field.h:276

+ Here is the call graph for this function:

bool Guild::BankTab::LoadItemFromDB ( Field fields)
370 {
371  uint8 slotId = fields[23].GetUInt8();
372  ObjectGuid::LowType itemGuid = fields[0].GetUInt64();
373  uint32 itemEntry = fields[1].GetUInt32();
374  if (slotId >= GUILD_BANK_MAX_SLOTS)
375  {
376  TC_LOG_ERROR("guild", "Invalid slot for item (GUID: " UI64FMTD ", id: %u) in guild bank, skipped.", itemGuid, itemEntry);
377  return false;
378  }
379 
380  ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemEntry);
381  if (!proto)
382  {
383  TC_LOG_ERROR("guild", "Unknown item (GUID: " UI64FMTD ", id: %u) in guild bank, skipped.", itemGuid, itemEntry);
384  return false;
385  }
386 
387  Item* pItem = NewItemOrBag(proto);
388  if (!pItem->LoadFromDB(itemGuid, ObjectGuid::Empty, fields, itemEntry))
389  {
390  TC_LOG_ERROR("guild", "Item (GUID " UI64FMTD ", id: %u) not found in item_instance, deleting from guild bank!", itemGuid, itemEntry);
391 
393  stmt->setUInt64(0, m_guildId);
394  stmt->setUInt8 (1, m_tabId);
395  stmt->setUInt8 (2, slotId);
397 
398  delete pItem;
399  return false;
400  }
401 
402  pItem->AddToWorld();
403  m_items[slotId] = pItem;
404  return true;
405 }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
uint64 GetUInt64() const
Definition: Field.h:184
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
virtual bool LoadFromDB(ObjectGuid::LowType guid, ObjectGuid ownerGuid, Field *fields, uint32 entry)
Definition: Item.cpp:411
uint64 LowType
Definition: ObjectGuid.h:199
ObjectGuid::LowType m_guildId
Definition: Guild.h:650
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: PreparedStatement.h:74
uint8 GetUInt8() const
Definition: Field.h:70
uint8 m_tabId
Definition: Guild.h:651
Definition: CharacterDatabase.h:34
Item * NewItemOrBag(ItemTemplate const *proto)
Definition: Bag.h:69
Definition: Item.h:259
#define UI64FMTD
Definition: Define.h:137
uint32_t uint32
Definition: Define.h:150
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
virtual void AddToWorld()
Definition: Object.cpp:142
Item * m_items[GUILD_BANK_MAX_SLOTS]
Definition: Guild.h:653
Definition: ItemTemplate.h:647
uint32 GetUInt32() const
Definition: Field.h:146
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 TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: Guild.h:45

+ Here is the call graph for this function:

void Guild::BankTab::SendText ( Guild const guild,
WorldSession session 
) const
485 {
487  textQuery.Tab = m_tabId;
488  textQuery.Text = m_text;
489 
490  if (session)
491  {
492  TC_LOG_DEBUG("guild", "SMSG_GUILD_BANK_QUERY_TEXT_RESULT [%s]: Tabid: %u, Text: %s"
493  , session->GetPlayerInfo().c_str(), m_tabId, m_text.c_str());
494  session->SendPacket(textQuery.Write());
495  }
496  else
497  {
498  TC_LOG_DEBUG("guild", "SMSG_GUILD_BANK_QUERY_TEXT_RESULT [Broadcast]: Tabid: %u, Text: %s", m_tabId, m_text.c_str());
499  guild->BroadcastPacket(textQuery.Write());
500  }
501 }
std::string m_text
Definition: Guild.h:656
std::string Text
Definition: GuildPackets.h:896
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
int32 Tab
Definition: GuildPackets.h:895
uint8 m_tabId
Definition: Guild.h:651
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
Definition: GuildPackets.h:888
WorldPacket const * Write() override
Definition: GuildPackets.cpp:711

+ Here is the call graph for this function:

void Guild::BankTab::SetInfo ( std::string const name,
std::string const icon 
)
422 {
423  if (m_name == name && m_icon == icon)
424  return;
425 
426  m_name = name;
427  m_icon = icon;
428 
430  stmt->setString(0, m_name);
431  stmt->setString(1, m_icon);
432  stmt->setUInt64(2, m_guildId);
433  stmt->setUInt8 (3, m_tabId);
435 }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Definition: CharacterDatabase.h:192
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
ObjectGuid::LowType m_guildId
Definition: Guild.h:650
Definition: PreparedStatement.h:74
uint8 m_tabId
Definition: Guild.h:651
std::string m_icon
Definition: Guild.h:655
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
std::string m_name
Definition: Guild.h:654

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Guild::BankTab::SetItem ( SQLTransaction trans,
uint8  slotId,
Item item 
)
455 {
456  if (slotId >= GUILD_BANK_MAX_SLOTS)
457  return false;
458 
459  m_items[slotId] = item;
460 
462  stmt->setUInt64(0, m_guildId);
463  stmt->setUInt8 (1, m_tabId);
464  stmt->setUInt8 (2, slotId);
465  CharacterDatabase.ExecuteOrAppend(trans, stmt);
466 
467  if (item)
468  {
470  stmt->setUInt64(0, m_guildId);
471  stmt->setUInt8 (1, m_tabId);
472  stmt->setUInt8 (2, slotId);
473  stmt->setUInt64(3, item->GetGUID().GetCounter());
474  CharacterDatabase.ExecuteOrAppend(trans, stmt);
475 
478  item->FSetState(ITEM_NEW);
479  item->SaveToDB(trans); // Not in inventory and can be saved standalone
480  }
481  return true;
482 }
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
void ExecuteOrAppend(SQLTransaction &trans, PreparedStatement *stmt)
Definition: DatabaseWorkerPool.h:236
Definition: UpdateFields.h:43
void FSetState(ItemUpdateState state)
Definition: Item.h:377
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
void SetGuidValue(uint16 index, ObjectGuid const &value)
Definition: Object.cpp:1120
ObjectGuid::LowType m_guildId
Definition: Guild.h:650
Definition: PreparedStatement.h:74
virtual void SaveToDB(SQLTransaction &trans)
Definition: Item.cpp:311
uint8 m_tabId
Definition: Guild.h:651
Definition: CharacterDatabase.h:171
Definition: CharacterDatabase.h:170
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Item * m_items[GUILD_BANK_MAX_SLOTS]
Definition: Guild.h:653
ObjectGuid const & GetGUID() const
Definition: Object.h:105
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
void SetOwnerGUID(ObjectGuid guid)
Definition: Item.h:273
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: Item.h:218
Definition: Guild.h:45
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::BankTab::SetText ( std::string const text)
438 {
439  if (m_text == text)
440  return;
441 
442  m_text = text;
443  utf8truncate(m_text, MAX_GUILD_BANK_TAB_TEXT_LEN); // DB and client size limitation
444 
446  stmt->setString(0, m_text);
447  stmt->setUInt64(1, m_guildId);
448  stmt->setUInt8 (2, m_tabId);
450 }
std::string m_text
Definition: Guild.h:656
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
void utf8truncate(std::string &utf8str, size_t len)
Definition: Util.cpp:260
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
Definition: CharacterDatabase.h:195
ObjectGuid::LowType m_guildId
Definition: Guild.h:650
Definition: PreparedStatement.h:74
uint8 m_tabId
Definition: Guild.h:651
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
#define MAX_GUILD_BANK_TAB_TEXT_LEN
Definition: Guild.cpp:36
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:

void Guild::BankTab::WriteInfoPacket ( WorldPacket data) const
inline
633  {
634  data << m_name;
635  data << m_icon;
636  }
std::string m_icon
Definition: Guild.h:655
std::string m_name
Definition: Guild.h:654
void Guild::BankTab::WritePacket ( WorldPacket data) const
bool Guild::BankTab::WriteSlotPacket ( WorldPacket data,
uint8  slotId,
bool  ignoreEmpty = true 
) const

Member Data Documentation

ObjectGuid::LowType Guild::BankTab::m_guildId
private
std::string Guild::BankTab::m_icon
private
Item* Guild::BankTab::m_items[GUILD_BANK_MAX_SLOTS]
private
std::string Guild::BankTab::m_name
private
uint8 Guild::BankTab::m_tabId
private
std::string Guild::BankTab::m_text
private

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