[Commands] Cleanup #npcedit, #lastname, #title, and #titlesuffix Commands. (#2215)

* [Commands] Cleanup #lastname, #npcedit, #title, and #titlesuffix Commands.
- Cleanup messages and logic.

* Update emu_constants.h

* Update command.cpp

* Update command.cpp

* Cleanup of GetXName methods to not define map unnecessarily.

* Update emu_constants.cpp

* Update npcedit.cpp
This commit is contained in:
Kinglykrab
2022-05-28 14:35:05 -04:00
committed by GitHub
parent 7de50d0e60
commit c8f6dbb86d
7 changed files with 2577 additions and 1358 deletions
+17 -6
View File
@@ -9,20 +9,31 @@ void command_lastname(Client *c, const Seperator *sep)
LogInfo("#lastname request from [{}] for [{}]", c->GetCleanName(), target->GetCleanName());
std::string last_name = sep->arg[1];
bool is_remove = !strcasecmp(sep->argplus[1], "-1");
std::string last_name = is_remove ? "" : sep->argplus[1];
if (last_name.size() > 64) {
c->Message(Chat::White, "Usage: #lastname [Last Name] (Last Name must be 64 characters or less)");
c->Message(Chat::White, "Last name must be 64 characters or less.");
return;
}
target->ChangeLastName(last_name);
c->Message(
Chat::White,
fmt::format(
"{} now {} a last name of '{}'.",
c->GetTargetDescription(target, TargetDescriptionType::UCYou),
c == target ? "have" : "has",
last_name
"Last name has been {}{} for {}{}",
is_remove ? "removed" : "changed",
!is_remove ? " and saved" : "",
c->GetTargetDescription(target),
(
is_remove ?
"." :
fmt::format(
" to '{}'.",
last_name
)
)
).c_str()
);
}
+2444 -1302
View File
File diff suppressed because it is too large Load Diff
+6 -10
View File
@@ -5,16 +5,12 @@ void command_title(Client *c, const Seperator *sep)
{
int arguments = sep->argnum;
if (!arguments) {
c->Message(
Chat::White,
"Usage: #title [Remove|Title] [Save (0 = False, 1 = True)]"
);
c->Message(Chat::White, "Usage: #title [Title] (use \"-1\" to remove title)");
return;
}
bool is_remove = !strcasecmp(sep->arg[1], "remove");
std::string title = is_remove ? "" : sep->arg[1];
bool save_title = sep->IsNumber(2) ? atobool(sep->arg[2]) : false;
bool is_remove = !strcasecmp(sep->argplus[1], "-1");
std::string title = is_remove ? "" : sep->argplus[1];
auto target = c;
if (c->GetTarget() && c->GetTarget()->IsClient()) {
@@ -30,9 +26,9 @@ void command_title(Client *c, const Seperator *sep)
find_replace(title, "_", " ");
}
if (!save_title || is_remove) {
if (is_remove) {
target->SetAATitle(title);
} else if (save_title) {
} else {
title_manager.CreateNewPlayerTitle(target, title);
}
@@ -43,7 +39,7 @@ void command_title(Client *c, const Seperator *sep)
fmt::format(
"Title has been {}{} for {}{}",
is_remove ? "removed" : "changed",
!is_remove && save_title ? " and saved" : "",
!is_remove ? " and saved" : "",
c->GetTargetDescription(target),
(
is_remove ?
+6 -7
View File
@@ -7,14 +7,13 @@ void command_titlesuffix(Client *c, const Seperator *sep)
if (!arguments) {
c->Message(
Chat::White,
"Usage: #titlesuffix [Remove|Title] [Save (0 = False, 1 = True)]"
"Usage: #titlesuffix [Title Suffix] (use \"-1\" to remove title suffix)"
);
return;
}
bool is_remove = !strcasecmp(sep->arg[1], "remove");
std::string suffix = is_remove ? "" : sep->arg[1];
bool save_suffix = sep->IsNumber(2) ? atobool(sep->arg[2]) : false;
bool is_remove = !strcasecmp(sep->argplus[1], "-1");
std::string suffix = is_remove ? "" : sep->argplus[1];
auto target = c;
if (c->GetTarget() && c->GetTarget()->IsClient()) {
@@ -30,9 +29,9 @@ void command_titlesuffix(Client *c, const Seperator *sep)
find_replace(suffix, "_", " ");
}
if (!save_suffix || is_remove) {
if (is_remove) {
target->SetTitleSuffix(suffix);
} else if (save_suffix) {
} else {
title_manager.CreateNewPlayerSuffix(target, suffix);
}
@@ -43,7 +42,7 @@ void command_titlesuffix(Client *c, const Seperator *sep)
fmt::format(
"Title suffix has been {}{} for {}{}",
is_remove ? "removed" : "changed",
!is_remove && save_suffix ? " and saved" : "",
!is_remove ? " and saved" : "",
c->GetTargetDescription(target),
(
is_remove ?