AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
titles_commandscript Class Reference
Inheritance diagram for titles_commandscript:
CommandScript ScriptObject

Public Member Functions

 titles_commandscript ()
 
ChatCommandTable GetCommands () const override
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
const std::string & GetName () const
 
uint16 GetTotalAvailableHooks ()
 

Static Public Member Functions

static bool HandleTitlesCurrentCommand (ChatHandler *handler, Variant< Hyperlink< title >, uint16 > titleId)
 
static bool HandleTitlesAddCommand (ChatHandler *handler, Variant< Hyperlink< title >, uint16 > titleId)
 
static bool HandleTitlesRemoveCommand (ChatHandler *handler, Variant< Hyperlink< title >, uint16 > titleId)
 
static bool HandleTitlesSetMaskCommand (ChatHandler *handler, uint64 mask)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name, uint16 totalAvailableHooks=0)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ titles_commandscript()

titles_commandscript::titles_commandscript ( )
inline
29: CommandScript("titles_commandscript") { }
Definition CommandScript.h:25

Member Function Documentation

◆ GetCommands()

ChatCommandTable titles_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

32 {
33 static ChatCommandTable titlesSetCommandTable =
34 {
36 };
37 static ChatCommandTable titlesCommandTable =
38 {
42 { "set", titlesSetCommandTable },
43 };
44 static ChatCommandTable commandTable =
45 {
46 { "titles", titlesCommandTable },
47 };
48 return commandTable;
49 }
static bool HandleTitlesRemoveCommand(ChatHandler *handler, Variant< Hyperlink< title >, uint16 > titleId)
Definition cs_titles.cpp:111
static bool HandleTitlesAddCommand(ChatHandler *handler, Variant< Hyperlink< title >, uint16 > titleId)
Definition cs_titles.cpp:82
static bool HandleTitlesSetMaskCommand(ChatHandler *handler, uint64 mask)
Definition cs_titles.cpp:148
static bool HandleTitlesCurrentCommand(ChatHandler *handler, Variant< Hyperlink< title >, uint16 > titleId)
Definition cs_titles.cpp:51
std::vector< ChatCommandBuilder > ChatCommandTable
Definition ChatCommand.h:46
@ RBAC_PERM_COMMAND_TITLES_CURRENT
Definition RBAC.h:589
@ RBAC_PERM_COMMAND_TITLES_ADD
Definition RBAC.h:588
@ RBAC_PERM_COMMAND_TITLES_SET_MASK
Definition RBAC.h:591
@ RBAC_PERM_COMMAND_TITLES_REMOVE
Definition RBAC.h:590

References HandleTitlesAddCommand(), HandleTitlesCurrentCommand(), HandleTitlesRemoveCommand(), HandleTitlesSetMaskCommand(), rbac::RBAC_PERM_COMMAND_TITLES_ADD, rbac::RBAC_PERM_COMMAND_TITLES_CURRENT, rbac::RBAC_PERM_COMMAND_TITLES_REMOVE, and rbac::RBAC_PERM_COMMAND_TITLES_SET_MASK.

◆ HandleTitlesAddCommand()

static bool titles_commandscript::HandleTitlesAddCommand ( ChatHandler handler,
Variant< Hyperlink< title >, uint16 titleId 
)
inlinestatic
83 {
84 Player* target = handler->getSelectedPlayer();
85 if (!target)
86 {
88 return false;
89 }
90
91 // check online security
92 if (handler->HasLowerSecurity(target, ObjectGuid::Empty))
93 return false;
94
95 CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(titleId);
96 if (!titleInfo)
97 {
99 return false;
100 }
101
102 std::string tNameLink = handler->GetNameLink(target);
103 std::string titleNameStr = Acore::StringFormat(target->getGender() == GENDER_MALE ? titleInfo->nameMale[handler->GetSessionDbcLocale()] : titleInfo->nameFemale[handler->GetSessionDbcLocale()], target->GetName());
104
105 target->SetTitle(titleInfo);
106 handler->PSendSysMessage(LANG_TITLE_ADD_RES, uint32(titleId), titleNameStr, tNameLink);
107
108 return true;
109 }
DBCStorage< CharTitlesEntry > sCharTitlesStore(CharTitlesEntryfmt)
std::uint32_t uint32
Definition Define.h:107
@ LANG_TITLE_ADD_RES
Definition Language.h:403
@ LANG_INVALID_TITLE_ID
Definition Language.h:402
@ LANG_NO_CHAR_SELECTED
Definition Language.h:152
@ GENDER_MALE
Definition SharedDefines.h:61
virtual std::string GetNameLink() const
Definition Chat.h:198
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:219
virtual LocaleConstant GetSessionDbcLocale() const
Definition Chat.cpp:878
void SendErrorMessage(uint32 entry)
Definition Chat.cpp:224
Player * getSelectedPlayer() const
Definition Chat.cpp:382
bool HasLowerSecurity(Player *target, ObjectGuid guid=ObjectGuid::Empty, bool strong=false)
Definition Chat.cpp:65
static ObjectGuid const Empty
Definition ObjectGuid.h:120
Definition Player.h:1084
void SetTitle(CharTitlesEntry const *title, bool lost=false)
Definition Player.cpp:13389
const std::string & GetName() const
Definition ScriptObject.h:53
uint8 getGender() const
Definition Unit.h:848
std::string StringFormat(FormatStringView fmt, Args &&... args)
Default AC string format function.
Definition StringFormat.h:44
Definition DBCStructure.h:632
char const * nameMale[16]
Definition DBCStructure.h:635

References ObjectGuid::Empty, GENDER_MALE, Unit::getGender(), WorldObject::GetName(), ChatHandler::GetNameLink(), ChatHandler::getSelectedPlayer(), ChatHandler::GetSessionDbcLocale(), ChatHandler::HasLowerSecurity(), LANG_INVALID_TITLE_ID, LANG_NO_CHAR_SELECTED, LANG_TITLE_ADD_RES, CharTitlesEntry::nameFemale, CharTitlesEntry::nameMale, ChatHandler::PSendSysMessage(), sCharTitlesStore, ChatHandler::SendErrorMessage(), Player::SetTitle(), and Acore::StringFormat().

Referenced by GetCommands().

◆ HandleTitlesCurrentCommand()

static bool titles_commandscript::HandleTitlesCurrentCommand ( ChatHandler handler,
Variant< Hyperlink< title >, uint16 titleId 
)
inlinestatic
52 {
53 Player* target = handler->getSelectedPlayer();
54 if (!target)
55 {
57 return false;
58 }
59
60 // check online security
61 if (handler->HasLowerSecurity(target, ObjectGuid::Empty))
62 return false;
63
64 CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(titleId);
65 if (!titleInfo)
66 {
68 return false;
69 }
70
71 std::string tNameLink = handler->GetNameLink(target);
72 std::string titleNameStr = Acore::StringFormat(target->getGender() == GENDER_MALE ? titleInfo->nameMale[handler->GetSessionDbcLocale()] : titleInfo->nameFemale[handler->GetSessionDbcLocale()], target->GetName());
73
74 target->SetTitle(titleInfo);
75 target->SetUInt32Value(PLAYER_CHOSEN_TITLE, titleInfo->bit_index);
76
77 handler->PSendSysMessage(LANG_TITLE_CURRENT_RES, uint32(titleId), titleNameStr, tNameLink);
78
79 return true;
80 }
@ LANG_TITLE_CURRENT_RES
Definition Language.h:405
@ PLAYER_CHOSEN_TITLE
Definition UpdateFields.h:324
void SetUInt32Value(uint16 index, uint32 value)
Definition Unit.cpp:17358
uint32 bit_index
Definition DBCStructure.h:639

References CharTitlesEntry::bit_index, ObjectGuid::Empty, GENDER_MALE, Unit::getGender(), WorldObject::GetName(), ChatHandler::GetNameLink(), ChatHandler::getSelectedPlayer(), ChatHandler::GetSessionDbcLocale(), ChatHandler::HasLowerSecurity(), LANG_INVALID_TITLE_ID, LANG_NO_CHAR_SELECTED, LANG_TITLE_CURRENT_RES, CharTitlesEntry::nameFemale, CharTitlesEntry::nameMale, PLAYER_CHOSEN_TITLE, ChatHandler::PSendSysMessage(), sCharTitlesStore, ChatHandler::SendErrorMessage(), Player::SetTitle(), Unit::SetUInt32Value(), and Acore::StringFormat().

Referenced by GetCommands().

◆ HandleTitlesRemoveCommand()

static bool titles_commandscript::HandleTitlesRemoveCommand ( ChatHandler handler,
Variant< Hyperlink< title >, uint16 titleId 
)
inlinestatic
112 {
113 Player* target = handler->getSelectedPlayer();
114 if (!target)
115 {
117 return false;
118 }
119
120 // check online security
121 if (handler->HasLowerSecurity(target, ObjectGuid::Empty))
122 return false;
123
124 CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(titleId);
125 if (!titleInfo)
126 {
128 return false;
129 }
130
131 target->SetTitle(titleInfo, true);
132
133 std::string tNameLink = handler->GetNameLink(target);
134 std::string titleNameStr = Acore::StringFormat(target->getGender() == GENDER_MALE ? titleInfo->nameMale[handler->GetSessionDbcLocale()] : titleInfo->nameFemale[handler->GetSessionDbcLocale()], target->GetName());
135
136 handler->PSendSysMessage(LANG_TITLE_REMOVE_RES, uint32(titleId), titleNameStr, tNameLink);
137
138 if (!target->HasTitle(target->GetInt32Value(PLAYER_CHOSEN_TITLE)))
139 {
141 handler->PSendSysMessage(LANG_CURRENT_TITLE_RESET, tNameLink);
142 }
143
144 return true;
145 }
@ LANG_TITLE_REMOVE_RES
Definition Language.h:404
@ LANG_CURRENT_TITLE_RESET
Definition Language.h:406
int32 GetInt32Value(uint16 index) const
Definition Object.cpp:288
bool HasTitle(uint32 bitIndex) const
Definition Player.cpp:13379

References ObjectGuid::Empty, GENDER_MALE, Unit::getGender(), Object::GetInt32Value(), WorldObject::GetName(), ChatHandler::GetNameLink(), ChatHandler::getSelectedPlayer(), ChatHandler::GetSessionDbcLocale(), ChatHandler::HasLowerSecurity(), Player::HasTitle(), LANG_CURRENT_TITLE_RESET, LANG_INVALID_TITLE_ID, LANG_NO_CHAR_SELECTED, LANG_TITLE_REMOVE_RES, CharTitlesEntry::nameFemale, CharTitlesEntry::nameMale, PLAYER_CHOSEN_TITLE, ChatHandler::PSendSysMessage(), sCharTitlesStore, ChatHandler::SendErrorMessage(), Player::SetTitle(), Unit::SetUInt32Value(), and Acore::StringFormat().

Referenced by GetCommands().

◆ HandleTitlesSetMaskCommand()

static bool titles_commandscript::HandleTitlesSetMaskCommand ( ChatHandler handler,
uint64  mask 
)
inlinestatic
149 {
150 Player* target = handler->getSelectedPlayer();
151 if (!target)
152 {
154 return false;
155 }
156
157 // check online security
158 if (handler->HasLowerSecurity(target, ObjectGuid::Empty))
159 return false;
160
161 uint64 titles2 = mask;
162
163 for (uint32 i = 1; i < sCharTitlesStore.GetNumRows(); ++i)
164 if (CharTitlesEntry const* tEntry = sCharTitlesStore.LookupEntry(i))
165 titles2 &= ~(uint64(1) << tEntry->bit_index);
166
167 mask &= ~titles2; // remove non-existing titles
168
170 handler->SendSysMessage(LANG_DONE);
171
172 if (!target->HasTitle(target->GetInt32Value(PLAYER_CHOSEN_TITLE)))
173 {
175 handler->PSendSysMessage(LANG_CURRENT_TITLE_RESET, handler->GetNameLink(target));
176 }
177
178 return true;
179 }
std::uint64_t uint64
Definition Define.h:106
@ LANG_DONE
Definition Language.h:75
@ PLAYER__FIELD_KNOWN_TITLES
Definition UpdateFields.h:335
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:168
void SetUInt64Value(uint16 index, uint64 value)
Definition Object.cpp:660

References ObjectGuid::Empty, Object::GetInt32Value(), ChatHandler::GetNameLink(), ChatHandler::getSelectedPlayer(), ChatHandler::HasLowerSecurity(), Player::HasTitle(), LANG_CURRENT_TITLE_RESET, LANG_DONE, LANG_NO_CHAR_SELECTED, PLAYER__FIELD_KNOWN_TITLES, PLAYER_CHOSEN_TITLE, ChatHandler::PSendSysMessage(), sCharTitlesStore, ChatHandler::SendErrorMessage(), ChatHandler::SendSysMessage(), Unit::SetUInt32Value(), and Object::SetUInt64Value().

Referenced by GetCommands().


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