[Commands] Cleanup #corpsefix Command. (#2197)

* [Commands] Cleanup #corpsefix Command.
- Cleanup messages and logic.

* Update entity.cpp
This commit is contained in:
Kinglykrab 2022-05-27 14:46:26 -04:00 committed by GitHub
parent 129a738072
commit e6db71e31e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3308,18 +3308,44 @@ uint32 EntityList::DeleteNPCCorpses()
void EntityList::CorpseFix(Client* c) void EntityList::CorpseFix(Client* c)
{ {
uint32 fixed_count = 0;
for (const auto& e : corpse_list) {
auto cur = e.second;
if (cur->IsNPCCorpse()) {
if (DistanceNoZ(c->GetPosition(), cur->GetPosition()) < 100) {
c->Message(
Chat::White,
fmt::format(
"Attempting to fix {}.",
cur->GetCleanName()
).c_str()
);
auto it = corpse_list.begin(); cur->GMMove(
while (it != corpse_list.end()) { cur->GetX(),
Corpse* corpse = it->second; cur->GetY(),
if (corpse->IsNPCCorpse()) { cur->GetFixedZ(c->GetPosition()),
if (DistanceNoZ(c->GetPosition(), corpse->GetPosition()) < 100) { c->GetHeading()
c->Message(Chat::Yellow, "Attempting to fix %s", it->second->GetCleanName()); );
corpse->GMMove(corpse->GetX(), corpse->GetY(), c->GetZ() + 2, 0);
fixed_count++;
} }
} }
++it;
} }
if (!fixed_count) {
c->Message(Chat::White, "There were no nearby NPC corpses to fix.");
return;
}
c->Message(
Chat::White,
fmt::format(
"Fixed {} nearby NPC corpse{}.",
fixed_count,
fixed_count != 1 ? "s" : ""
).c_str()
);
} }
// returns the number of corpses deleted. A negative number indicates an error code. // returns the number of corpses deleted. A negative number indicates an error code.