mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
* [Titles] Cleanup titles, title suffix, and last name methods. - Use strings instead of const chars*. - Add optional parameter to SetAATitle in Lua so you can save to the database similar to Perl. - Cleanup #lastname command. - Cleanup #title command. - Cleanup #titlesuffix command. * Update npc.cpp
59 lines
1.2 KiB
C++
Executable File
59 lines
1.2 KiB
C++
Executable File
#include "../client.h"
|
|
#include "../titles.h"
|
|
|
|
void command_titlesuffix(Client *c, const Seperator *sep)
|
|
{
|
|
int arguments = sep->argnum;
|
|
if (!arguments) {
|
|
c->Message(
|
|
Chat::White,
|
|
"Usage: #titlesuffix [Remove|Title] [Save (0 = False, 1 = True)]"
|
|
);
|
|
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;
|
|
|
|
auto target = c;
|
|
if (c->GetTarget() && c->GetTarget()->IsClient()) {
|
|
target = c->GetTarget()->CastToClient();
|
|
}
|
|
|
|
if (suffix.size() > 31) {
|
|
c->Message(Chat::White, "Title suffix must be 31 characters or less.");
|
|
return;
|
|
}
|
|
|
|
if (!suffix.empty()) {
|
|
find_replace(suffix, "_", " ");
|
|
}
|
|
|
|
if (!save_suffix || is_remove) {
|
|
target->SetTitleSuffix(suffix);
|
|
} else if (save_suffix) {
|
|
title_manager.CreateNewPlayerSuffix(target, suffix);
|
|
}
|
|
|
|
target->Save();
|
|
|
|
c->Message(
|
|
Chat::White,
|
|
fmt::format(
|
|
"Title suffix has been {}{} for {}{}",
|
|
is_remove ? "removed" : "changed",
|
|
!is_remove && save_suffix ? " and saved" : "",
|
|
c->GetTargetDescription(target),
|
|
(
|
|
is_remove ?
|
|
"." :
|
|
fmt::format(
|
|
" to '{}'.",
|
|
suffix
|
|
)
|
|
)
|
|
).c_str()
|
|
);
|
|
}
|