1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-09-15 06:52:34 +02:00

Improved function for destroying effects

Old version (needlessly) iterates on all vector
This commit is contained in:
Filip Gawin 2018-10-09 21:33:37 +02:00
parent 5b135a5689
commit 35405534e7

View File

@ -552,10 +552,13 @@ TrailFX& GameWorld::createTrailEffect() {
}
void GameWorld::destroyEffect(VisualFX& effect) {
effects.erase(
std::remove_if(effects.begin(), effects.end(),
[&effect](auto& ef) { return ef.get() == &effect; }),
effects.end());
auto found =
std::find_if(effects.begin(), effects.end(),
[&effect](auto& ef) { return ef.get() == &effect; });
if (found != effects.end()) {
effects.erase(found);
}
}
void GameWorld::doWeaponScan(const WeaponScan& scan) {