Move player corpses on instance shutdown

Moves corpses to graveyard when an expired instance shuts down.
Zones without a graveyard move them to non-instance version instead.

Fixes player corpses being left inside instances that expire
before graveyards process or in instances without a graveyard
This commit is contained in:
hg
2021-01-02 19:19:31 -05:00
parent de5b7f472d
commit 6c8c81f3db
8 changed files with 118 additions and 17 deletions
+40
View File
@@ -5225,3 +5225,43 @@ void EntityList::GateAllClientsToSafeReturn()
}
}
}
int EntityList::MovePlayerCorpsesToGraveyard(bool force_move_from_instance)
{
if (!zone)
{
return 0;
}
int moved_count = 0;
for (auto it = corpse_list.begin(); it != corpse_list.end();)
{
bool moved = false;
if (it->second && it->second->IsPlayerCorpse())
{
if (zone->HasGraveyard())
{
moved = it->second->MovePlayerCorpseToGraveyard();
}
else if (force_move_from_instance && zone->GetInstanceID() != 0)
{
moved = it->second->MovePlayerCorpseToNonInstance();
}
}
if (moved)
{
safe_delete(it->second);
free_ids.push(it->first);
it = corpse_list.erase(it);
++moved_count;
}
else
{
++it;
}
}
return moved_count;
}