[Commands] Cleanup #save Command. (#2136)

- Cleanup messages and logic.
This commit is contained in:
Kinglykrab 2022-05-06 19:50:19 -04:00 committed by GitHub
parent e2bfa44df0
commit bf7c1252f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,31 +3,38 @@
void command_save(Client *c, const Seperator *sep) void command_save(Client *c, const Seperator *sep)
{ {
if (c->GetTarget() == 0) { if (
c->Message(Chat::White, "Error: no target"); !c->GetTarget() ||
(
c->GetTarget() &&
!c->GetTarget()->IsClient() &&
!c->GetTarget()->IsPlayerCorpse()
)
) {
c->Message(Chat::White, "You must target a player or player corpse to use this command.");
return;
} }
else if (c->GetTarget()->IsClient()) {
if (c->GetTarget()->CastToClient()->Save(2)) { if (c->GetTarget()->IsClient()) {
c->Message(Chat::White, "%s successfully saved.", c->GetTarget()->GetName()); c->Message(
} Chat::White,
else { fmt::format(
c->Message(Chat::White, "Manual save for %s failed.", c->GetTarget()->GetName()); "{} ({}) {} saved.",
} c->GetTarget()->GetCleanName(),
} c->GetTarget()->GetID(),
else if (c->GetTarget()->IsPlayerCorpse()) { c->GetTarget()->CastToClient()->Save(2) ? "successfully" : "failed to be"
if (c->GetTarget()->CastToMob()->Save()) { ).c_str()
c->Message( );
Chat::White, } else if (c->GetTarget()->IsPlayerCorpse()) {
"%s successfully saved. (dbid=%u)", c->Message(
c->GetTarget()->GetName(), Chat::White,
c->GetTarget()->CastToCorpse()->GetCorpseDBID()); fmt::format(
} "{} ({}) {} saved.",
else { c->GetTarget()->GetCleanName(),
c->Message(Chat::White, "Manual save for %s failed.", c->GetTarget()->GetName()); c->GetTarget()->CastToCorpse()->GetCorpseDBID(),
} c->GetTarget()->CastToMob()->Save() ? "successfully" : "failed to be"
} ).c_str()
else { );
c->Message(Chat::White, "Error: target not a Client/PlayerCorpse");
} }
} }