diff --git a/zone/entity.cpp b/zone/entity.cpp index 1f786cb4c..918b1ec2a 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -3308,18 +3308,44 @@ uint32 EntityList::DeleteNPCCorpses() 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(); - while (it != corpse_list.end()) { - Corpse* corpse = it->second; - if (corpse->IsNPCCorpse()) { - if (DistanceNoZ(c->GetPosition(), corpse->GetPosition()) < 100) { - c->Message(Chat::Yellow, "Attempting to fix %s", it->second->GetCleanName()); - corpse->GMMove(corpse->GetX(), corpse->GetY(), c->GetZ() + 2, 0); + cur->GMMove( + cur->GetX(), + cur->GetY(), + cur->GetFixedZ(c->GetPosition()), + c->GetHeading() + ); + + 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.