From 3a50470dbbb843e519bbaa1152fc5017211e7347 Mon Sep 17 00:00:00 2001 From: David Markowitz Date: Sat, 27 Jan 2024 21:48:12 -0800 Subject: [PATCH] use erase remove if --- dGame/Entity.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index dafa732e..0dc0c99a 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -1988,13 +1988,9 @@ void Entity::SetNetworkId(const uint16_t id) { std::vector Entity::GetTargetsInPhantom() { // Clean up invalid targets, like disconnected players - for (auto i = 0u; i < m_TargetsInPhantom.size(); ) { - if (Game::entityManager->GetEntity(m_TargetsInPhantom.at(i))) { - i++; - continue; - } - m_TargetsInPhantom.erase(m_TargetsInPhantom.begin() + i); - } + m_TargetsInPhantom.erase(std::remove_if(m_TargetsInPhantom.begin(), m_TargetsInPhantom.end(), [](const LWOOBJID id) { + return !Game::entityManager->GetEntity(id); + }), m_TargetsInPhantom.end()); std::vector enemies; for (const auto id : m_TargetsInPhantom) {