aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Accounts/RBAC.h4
-rw-r--r--src/server/scripts/Commands/cs_titles.cpp117
2 files changed, 35 insertions, 86 deletions
diff --git a/src/server/game/Accounts/RBAC.h b/src/server/game/Accounts/RBAC.h
index 24d8ba51557..3851d2a94f8 100644
--- a/src/server/game/Accounts/RBAC.h
+++ b/src/server/game/Accounts/RBAC.h
@@ -626,11 +626,11 @@ enum RBACPermissions
RBAC_PERM_COMMAND_TICKET_UNASSIGN = 758,
RBAC_PERM_COMMAND_TICKET_VIEWID = 759,
RBAC_PERM_COMMAND_TICKET_VIEWNAME = 760,
- RBAC_PERM_COMMAND_TITLES = 761,
+ // 761 previously used, do not reuse
RBAC_PERM_COMMAND_TITLES_ADD = 762,
RBAC_PERM_COMMAND_TITLES_CURRENT = 763,
RBAC_PERM_COMMAND_TITLES_REMOVE = 764,
- RBAC_PERM_COMMAND_TITLES_SET = 765,
+ // 765 previously used, do not reuse
RBAC_PERM_COMMAND_TITLES_SET_MASK = 766,
RBAC_PERM_COMMAND_WP = 767,
RBAC_PERM_COMMAND_WP_ADD = 768,
diff --git a/src/server/scripts/Commands/cs_titles.cpp b/src/server/scripts/Commands/cs_titles.cpp
index 86eff95c1f8..0175d72ca59 100644
--- a/src/server/scripts/Commands/cs_titles.cpp
+++ b/src/server/scripts/Commands/cs_titles.cpp
@@ -29,50 +29,35 @@ EndScriptData */
#include "Player.h"
#include "RBAC.h"
-#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
+using namespace Trinity::ChatCommands;
class titles_commandscript : public CommandScript
{
public:
titles_commandscript() : CommandScript("titles_commandscript") { }
- std::vector<ChatCommand> GetCommands() const override
+ ChatCommandTable GetCommands() const override
{
- static std::vector<ChatCommand> titlesSetCommandTable =
+ static ChatCommandTable titlesSetCommandTable =
{
- { "mask", rbac::RBAC_PERM_COMMAND_TITLES_SET_MASK, false, &HandleTitlesSetMaskCommand, "" },
+ { "mask", HandleTitlesSetMaskCommand, rbac::RBAC_PERM_COMMAND_TITLES_SET_MASK, Console::No },
};
- static std::vector<ChatCommand> titlesCommandTable =
+ static ChatCommandTable titlesCommandTable =
{
- { "add", rbac::RBAC_PERM_COMMAND_TITLES_ADD, false, &HandleTitlesAddCommand, "" },
- { "current", rbac::RBAC_PERM_COMMAND_TITLES_CURRENT, false, &HandleTitlesCurrentCommand, "" },
- { "remove", rbac::RBAC_PERM_COMMAND_TITLES_REMOVE, false, &HandleTitlesRemoveCommand, "" },
- { "set", rbac::RBAC_PERM_COMMAND_TITLES_SET, false, nullptr, "", titlesSetCommandTable },
+ { "add", HandleTitlesAddCommand, rbac::RBAC_PERM_COMMAND_TITLES_ADD, Console::No },
+ { "current", HandleTitlesCurrentCommand, rbac::RBAC_PERM_COMMAND_TITLES_CURRENT, Console::No },
+ { "remove", HandleTitlesRemoveCommand, rbac::RBAC_PERM_COMMAND_TITLES_REMOVE, Console::No },
+ { "set", titlesSetCommandTable },
};
- static std::vector<ChatCommand> commandTable =
+ static ChatCommandTable commandTable =
{
- { "titles", rbac::RBAC_PERM_COMMAND_TITLES, false, nullptr, "", titlesCommandTable },
+ { "titles", titlesCommandTable },
};
return commandTable;
}
- static bool HandleTitlesCurrentCommand(ChatHandler* handler, char const* args)
+ static bool HandleTitlesCurrentCommand(ChatHandler* handler, Variant<Hyperlink<title>, uint16> titleId)
{
- // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r
- char* id_p = handler->extractKeyFromLink((char*)args, "Htitle");
- if (!id_p)
- return false;
-
- int32 id = atoi(id_p);
- if (id <= 0)
- {
- handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
Player* target = handler->getSelectedPlayer();
if (!target)
{
@@ -85,39 +70,27 @@ public:
if (handler->HasLowerSecurity(target, ObjectGuid::Empty))
return false;
- CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id);
+ CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(titleId);
if (!titleInfo)
{
- handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id);
+ handler->PSendSysMessage(LANG_INVALID_TITLE_ID, titleId);
handler->SetSentErrorMessage(true);
return false;
}
std::string tNameLink = handler->GetNameLink(target);
+ std::string titleNameStr = Trinity::StringFormat(target->GetNativeGender() == GENDER_MALE ? titleInfo->Name[handler->GetSessionDbcLocale()] : titleInfo->Name1[handler->GetSessionDbcLocale()], target->GetName());
- target->SetTitle(titleInfo); // to be sure that title now known
+ target->SetTitle(titleInfo);
target->SetUInt32Value(PLAYER_CHOSEN_TITLE, titleInfo->MaskID);
- handler->PSendSysMessage(LANG_TITLE_CURRENT_RES, id, target->GetNativeGender() == GENDER_MALE ? titleInfo->Name[handler->GetSessionDbcLocale()] : titleInfo->Name1[handler->GetSessionDbcLocale()], tNameLink.c_str());
+ handler->PSendSysMessage(LANG_TITLE_CURRENT_RES, titleId, titleNameStr, tNameLink);
return true;
}
- static bool HandleTitlesAddCommand(ChatHandler* handler, char const* args)
+ static bool HandleTitlesAddCommand(ChatHandler* handler, Variant<Hyperlink<title>, uint16> titleId)
{
- // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r
- char* id_p = handler->extractKeyFromLink((char*)args, "Htitle");
- if (!id_p)
- return false;
-
- int32 id = atoi(id_p);
- if (id <= 0)
- {
- handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
Player* target = handler->getSelectedPlayer();
if (!target)
{
@@ -130,40 +103,25 @@ public:
if (handler->HasLowerSecurity(target, ObjectGuid::Empty))
return false;
- CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id);
+ CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(titleId);
if (!titleInfo)
{
- handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id);
+ handler->PSendSysMessage(LANG_INVALID_TITLE_ID, titleId);
handler->SetSentErrorMessage(true);
return false;
}
std::string tNameLink = handler->GetNameLink(target);
-
- char titleNameStr[80];
- snprintf(titleNameStr, 80, target->GetNativeGender() == GENDER_MALE ? titleInfo->Name[handler->GetSessionDbcLocale()] : titleInfo->Name1[handler->GetSessionDbcLocale()], target->GetName().c_str());
+ std::string titleNameStr = Trinity::StringFormat(target->GetNativeGender() == GENDER_MALE ? titleInfo->Name[handler->GetSessionDbcLocale()] : titleInfo->Name1[handler->GetSessionDbcLocale()], target->GetName());
target->SetTitle(titleInfo);
- handler->PSendSysMessage(LANG_TITLE_ADD_RES, id, titleNameStr, tNameLink.c_str());
+ handler->PSendSysMessage(LANG_TITLE_ADD_RES, titleId, titleNameStr, tNameLink);
return true;
}
- static bool HandleTitlesRemoveCommand(ChatHandler* handler, char const* args)
+ static bool HandleTitlesRemoveCommand(ChatHandler* handler, Variant<Hyperlink<title>, uint16> titleId)
{
- // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r
- char* id_p = handler->extractKeyFromLink((char*)args, "Htitle");
- if (!id_p)
- return false;
-
- int32 id = atoi(id_p);
- if (id <= 0)
- {
- handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
Player* target = handler->getSelectedPlayer();
if (!target)
{
@@ -176,10 +134,10 @@ public:
if (handler->HasLowerSecurity(target, ObjectGuid::Empty))
return false;
- CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id);
+ CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(titleId);
if (!titleInfo)
{
- handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id);
+ handler->PSendSysMessage(LANG_INVALID_TITLE_ID, titleId);
handler->SetSentErrorMessage(true);
return false;
}
@@ -187,31 +145,22 @@ public:
target->SetTitle(titleInfo, true);
std::string tNameLink = handler->GetNameLink(target);
+ std::string titleNameStr = Trinity::StringFormat(target->GetNativeGender() == GENDER_MALE ? titleInfo->Name[handler->GetSessionDbcLocale()] : titleInfo->Name1[handler->GetSessionDbcLocale()], target->GetName());
- char titleNameStr[80];
- snprintf(titleNameStr, 80, target->GetNativeGender() == GENDER_MALE ? titleInfo->Name[handler->GetSessionDbcLocale()] : titleInfo->Name1[handler->GetSessionDbcLocale()], target->GetName().c_str());
-
- handler->PSendSysMessage(LANG_TITLE_REMOVE_RES, id, titleNameStr, tNameLink.c_str());
+ handler->PSendSysMessage(LANG_TITLE_REMOVE_RES, titleId, titleNameStr, tNameLink);
if (!target->HasTitle(target->GetInt32Value(PLAYER_CHOSEN_TITLE)))
{
target->SetUInt32Value(PLAYER_CHOSEN_TITLE, 0);
- handler->PSendSysMessage(LANG_CURRENT_TITLE_RESET, tNameLink.c_str());
+ handler->PSendSysMessage(LANG_CURRENT_TITLE_RESET, tNameLink);
}
return true;
}
//Edit Player KnownTitles
- static bool HandleTitlesSetMaskCommand(ChatHandler* handler, char const* args)
+ static bool HandleTitlesSetMaskCommand(ChatHandler* handler, uint64 mask)
{
- if (!*args)
- return false;
-
- uint64 titles = 0;
-
- sscanf((char*)args, UI64FMTD, &titles);
-
Player* target = handler->getSelectedPlayer();
if (!target)
{
@@ -224,21 +173,21 @@ public:
if (handler->HasLowerSecurity(target, ObjectGuid::Empty))
return false;
- uint64 titles2 = titles;
+ uint64 titles2 = mask;
for (uint32 i = 1; i < sCharTitlesStore.GetNumRows(); ++i)
if (CharTitlesEntry const* tEntry = sCharTitlesStore.LookupEntry(i))
titles2 &= ~(uint64(1) << tEntry->MaskID);
- titles &= ~titles2; // remove non-existing titles
+ mask &= ~titles2; // remove non-existing titles
- target->SetUInt64Value(PLAYER__FIELD_KNOWN_TITLES, titles);
+ target->SetUInt64Value(PLAYER__FIELD_KNOWN_TITLES, mask);
handler->SendSysMessage(LANG_DONE);
if (!target->HasTitle(target->GetInt32Value(PLAYER_CHOSEN_TITLE)))
{
target->SetUInt32Value(PLAYER_CHOSEN_TITLE, 0);
- handler->PSendSysMessage(LANG_CURRENT_TITLE_RESET, handler->GetNameLink(target).c_str());
+ handler->PSendSysMessage(LANG_CURRENT_TITLE_RESET, handler->GetNameLink(target));
}
return true;