From 4f550fcbf3da51fb463f08777978149f3c8598e5 Mon Sep 17 00:00:00 2001 From: Kinglykrab <89047260+Kinglykrab@users.noreply.github.com> Date: Sun, 14 Nov 2021 14:09:10 -0500 Subject: [PATCH] [Commands] Cleanup #loc Command. (#1752) - Cleanup message and logic. --- zone/command.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/zone/command.cpp b/zone/command.cpp index ae4aeac53..fbb790307 100755 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -7308,9 +7308,32 @@ void command_spawnfix(Client *c, const Seperator *sep) { void command_loc(Client *c, const Seperator *sep) { - Mob *t=c->GetTarget()?c->GetTarget():c->CastToMob(); + Mob *target = c; + if (c->GetTarget()) { + target = c->GetTarget(); + } - c->Message(Chat::White, "%s's Location (XYZ): %1.2f, %1.2f, %1.2f; heading=%1.1f", t->GetName(), t->GetX(), t->GetY(), t->GetZ(), t->GetHeading()); + auto target_position = target->GetPosition(); + + c->Message( + Chat::White, + fmt::format( + "{} Location | XYZ: {:.2f}, {:.2f}, {:.2f} Heading: {:.2f}", + ( + c == target ? + "Your" : + fmt::format( + "{} ({})", + target->GetCleanName(), + target->GetID() + ) + ), + target_position.x, + target_position.y, + target_position.z, + target_position.w + ).c_str() + ); } void command_goto(Client *c, const Seperator *sep)