AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Guild::RankInfo Class Reference

Public Member Functions

 RankInfo ()
 
 RankInfo (uint32 guildId)
 
 RankInfo (uint32 guildId, uint8 rankId, std::string_view name, uint32 rights, uint32 money)
 
void LoadFromDB (Field *fields)
 
void SaveToDB (CharacterDatabaseTransaction trans) const
 
uint8 GetId () const
 
std::string const & GetName () const
 
void SetName (std::string_view name)
 
uint32 GetRights () const
 
void SetRights (uint32 rights)
 
int32 GetBankMoneyPerDay () const
 
void SetBankMoneyPerDay (uint32 money)
 
int8 GetBankTabRights (uint8 tabId) const
 
int32 GetBankTabSlotsPerDay (uint8 tabId) const
 
void SetBankTabSlotsAndRights (GuildBankRightsAndSlots rightsAndSlots, bool saveToDB)
 
void CreateMissingTabsIfNeeded (uint8 ranks, CharacterDatabaseTransaction trans, bool logOnCreate=false)
 

Private Attributes

uint32 m_guildId
 
uint8 m_rankId
 
std::string m_name
 
uint32 m_rights
 
uint32 m_bankMoneyPerDay
 
std::array< GuildBankRightsAndSlots, GUILD_BANK_MAX_TABSm_bankTabRightsAndSlots = {}
 

Detailed Description

Constructor & Destructor Documentation

◆ RankInfo() [1/3]

Guild::RankInfo::RankInfo ( )
inline
@ GUILD_RANK_NONE
Definition: Guild.h:50
@ GR_RIGHT_EMPTY
Definition: Guild.h:79
uint32 m_rights
Definition: Guild.h:554
uint32 m_bankMoneyPerDay
Definition: Guild.h:555
uint32 m_guildId
Definition: Guild.h:550
uint8 m_rankId
Definition: Guild.h:552

◆ RankInfo() [2/3]

Guild::RankInfo::RankInfo ( uint32  guildId)
inline

◆ RankInfo() [3/3]

Guild::RankInfo::RankInfo ( uint32  guildId,
uint8  rankId,
std::string_view  name,
uint32  rights,
uint32  money 
)
inline
517 :
518 m_guildId(guildId), m_rankId(rankId), m_name(name), m_rights(rights),
@ GUILD_WITHDRAW_MONEY_UNLIMITED
Definition: Guild.h:51
@ GR_GUILDMASTER
Definition: Guild.h:68
std::string m_name
Definition: Guild.h:553

Member Function Documentation

◆ CreateMissingTabsIfNeeded()

void Guild::RankInfo::CreateMissingTabsIfNeeded ( uint8  ranks,
CharacterDatabaseTransaction  trans,
bool  logOnCreate = false 
)
287{
288 for (uint8 i = 0; i < tabs; ++i)
289 {
291 if (rightsAndSlots.GetTabId() == i)
292 continue;
293
294 rightsAndSlots.SetTabId(i);
296 rightsAndSlots.SetGuildMasterValues();
297
298 if (logOnCreate)
299 LOG_ERROR("guild", "Guild {} has broken Tab {} for rank {}. Created default tab.", m_guildId, i, m_rankId);
300
302 stmt->SetData(0, m_guildId);
303 stmt->SetData(1, i);
304 stmt->SetData(2, m_rankId);
305 stmt->SetData(3, rightsAndSlots.GetRights());
306 stmt->SetData(4, rightsAndSlots.GetSlots());
307 trans->Append(stmt);
308 }
309}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:156
std::uint8_t uint8
Definition: Define.h:109
@ CHAR_INS_GUILD_BANK_RIGHT
Definition: CharacterDatabase.h:156
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: PreparedStatement.h:158
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:78
Definition: Guild.h:266
void SetGuildMasterValues()
Definition: Guild.h:272
uint8 GetRights() const
Definition: Guild.h:284
uint32 GetSlots() const
Definition: Guild.h:283
uint8 GetTabId() const
Definition: Guild.h:282
void SetTabId(uint8 _tabId)
Definition: Guild.h:278
std::array< GuildBankRightsAndSlots, GUILD_BANK_MAX_TABS > m_bankTabRightsAndSlots
Definition: Guild.h:556

References CHAR_INS_GUILD_BANK_RIGHT, CharacterDatabase, GuildBankRightsAndSlots::GetRights(), GuildBankRightsAndSlots::GetSlots(), GuildBankRightsAndSlots::GetTabId(), GR_GUILDMASTER, LOG_ERROR, PreparedStatementBase::SetData(), GuildBankRightsAndSlots::SetGuildMasterValues(), and GuildBankRightsAndSlots::SetTabId().

Referenced by Guild::_CreateRank(), and Guild::Validate().

◆ GetBankMoneyPerDay()

int32 Guild::RankInfo::GetBankMoneyPerDay ( ) const
inline
532{ return m_bankMoneyPerDay; }

References m_bankMoneyPerDay.

◆ GetBankTabRights()

int8 Guild::RankInfo::GetBankTabRights ( uint8  tabId) const
inline
537 {
538 return tabId < GUILD_BANK_MAX_TABS ? m_bankTabRightsAndSlots[tabId].GetRights() : 0;
539 }
@ GUILD_BANK_MAX_TABS
Definition: Guild.h:45

References GUILD_BANK_MAX_TABS, and m_bankTabRightsAndSlots.

◆ GetBankTabSlotsPerDay()

int32 Guild::RankInfo::GetBankTabSlotsPerDay ( uint8  tabId) const
inline
542 {
543 return tabId < GUILD_BANK_MAX_TABS ? m_bankTabRightsAndSlots[tabId].GetSlots() : 0;
544 }

References GUILD_BANK_MAX_TABS, and m_bankTabRightsAndSlots.

◆ GetId()

uint8 Guild::RankInfo::GetId ( ) const
inline
524{ return m_rankId; }

References m_rankId.

Referenced by Guild::Validate().

◆ GetName()

std::string const & Guild::RankInfo::GetName ( ) const
inline
526{ return m_name; }

References m_name.

◆ GetRights()

uint32 Guild::RankInfo::GetRights ( ) const
inline
529{ return m_rights; }

References m_rights.

◆ LoadFromDB()

void Guild::RankInfo::LoadFromDB ( Field fields)
266{
267 m_rankId = fields[1].Get<uint8>();
268 m_name = fields[2].Get<std::string>();
269 m_rights = fields[3].Get<uint32>();
270 m_bankMoneyPerDay = fields[4].Get<uint32>();
271 if (m_rankId == GR_GUILDMASTER) // Prevent loss of leader rights
273}
std::uint32_t uint32
Definition: Define.h:107
@ GR_RIGHT_ALL
Definition: Guild.h:97
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:113

References Field::Get(), GR_GUILDMASTER, GR_RIGHT_ALL, and Guild::m_name.

Referenced by Guild::LoadRankFromDB().

◆ SaveToDB()

void Guild::RankInfo::SaveToDB ( CharacterDatabaseTransaction  trans) const
276{
278 stmt->SetData(0, m_guildId);
279 stmt->SetData (1, m_rankId);
280 stmt->SetData(2, m_name);
281 stmt->SetData(3, m_rights);
282 stmt->SetData(4, m_bankMoneyPerDay);
283 CharacterDatabase.ExecuteOrAppend(trans, stmt);
284}
@ CHAR_INS_GUILD_RANK
Definition: CharacterDatabase.h:147

References CHAR_INS_GUILD_RANK, CharacterDatabase, Guild::m_name, and PreparedStatementBase::SetData().

Referenced by Guild::_CreateRank().

◆ SetBankMoneyPerDay()

void Guild::RankInfo::SetBankMoneyPerDay ( uint32  money)
343{
344 if (m_rankId == GR_GUILDMASTER) // Prevent loss of leader rights
346
347 if (m_bankMoneyPerDay == money)
348 return;
349
350 m_bankMoneyPerDay = money;
351
353 stmt->SetData(0, money);
354 stmt->SetData (1, m_rankId);
355 stmt->SetData(2, m_guildId);
356 CharacterDatabase.Execute(stmt);
357}
@ CHAR_UPD_GUILD_RANK_BANK_MONEY
Definition: CharacterDatabase.h:177

References CHAR_UPD_GUILD_RANK_BANK_MONEY, CharacterDatabase, GR_GUILDMASTER, GUILD_WITHDRAW_MONEY_UNLIMITED, and PreparedStatementBase::SetData().

◆ SetBankTabSlotsAndRights()

void Guild::RankInfo::SetBankTabSlotsAndRights ( GuildBankRightsAndSlots  rightsAndSlots,
bool  saveToDB 
)
360{
361 if (m_rankId == GR_GUILDMASTER) // Prevent loss of leader rights
362 rightsAndSlots.SetGuildMasterValues();
363
364 GuildBankRightsAndSlots& guildBR = m_bankTabRightsAndSlots[rightsAndSlots.GetTabId()];
365 guildBR = rightsAndSlots;
366
367 if (saveToDB)
368 {
370 stmt->SetData(0, m_guildId);
371 stmt->SetData (1, guildBR.GetTabId());
372 stmt->SetData (2, m_rankId);
373 stmt->SetData (3, guildBR.GetRights());
374 stmt->SetData(4, guildBR.GetSlots());
375 CharacterDatabase.Execute(stmt);
376 }
377}

References CHAR_INS_GUILD_BANK_RIGHT, CharacterDatabase, GuildBankRightsAndSlots::GetRights(), GuildBankRightsAndSlots::GetSlots(), GuildBankRightsAndSlots::GetTabId(), GR_GUILDMASTER, PreparedStatementBase::SetData(), and GuildBankRightsAndSlots::SetGuildMasterValues().

◆ SetName()

void Guild::RankInfo::SetName ( std::string_view  name)
312{
313 if (m_name == name)
314 return;
315
316 m_name = name;
317
319 stmt->SetData(0, m_name);
320 stmt->SetData (1, m_rankId);
321 stmt->SetData(2, m_guildId);
322 CharacterDatabase.Execute(stmt);
323}
@ CHAR_UPD_GUILD_RANK_NAME
Definition: CharacterDatabase.h:171

References CHAR_UPD_GUILD_RANK_NAME, CharacterDatabase, Guild::m_name, and PreparedStatementBase::SetData().

◆ SetRights()

void Guild::RankInfo::SetRights ( uint32  rights)
326{
327 if (m_rankId == GR_GUILDMASTER) // Prevent loss of leader rights
328 rights = GR_RIGHT_ALL;
329
330 if (m_rights == rights)
331 return;
332
333 m_rights = rights;
334
336 stmt->SetData(0, m_rights);
337 stmt->SetData (1, m_rankId);
338 stmt->SetData(2, m_guildId);
339 CharacterDatabase.Execute(stmt);
340}
@ CHAR_UPD_GUILD_RANK_RIGHTS
Definition: CharacterDatabase.h:172

References CHAR_UPD_GUILD_RANK_RIGHTS, CharacterDatabase, GR_GUILDMASTER, GR_RIGHT_ALL, and PreparedStatementBase::SetData().

Member Data Documentation

◆ m_bankMoneyPerDay

uint32 Guild::RankInfo::m_bankMoneyPerDay
private

Referenced by GetBankMoneyPerDay().

◆ m_bankTabRightsAndSlots

std::array<GuildBankRightsAndSlots, GUILD_BANK_MAX_TABS> Guild::RankInfo::m_bankTabRightsAndSlots = {}
private

◆ m_guildId

uint32 Guild::RankInfo::m_guildId
private

◆ m_name

std::string Guild::RankInfo::m_name
private

Referenced by GetName().

◆ m_rankId

uint8 Guild::RankInfo::m_rankId
private

Referenced by GetId().

◆ m_rights

uint32 Guild::RankInfo::m_rights
private

Referenced by GetRights().