From 4a01fab66d98cf593e9e46e64d763393de019037 Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 11 Dec 2016 23:47:40 +0000 Subject: [PATCH] Fix failure to remove expired walls std::remove_if can be called on an iterator that returns a proxy object, but the results of that call are not generally useful. When remove_if attempts to move-assign over removed elements, it instead assigns over the temporary proxy object. If the proxy object has typical move semantics, move-assigning over it has no effect on the underlying container. Revert to using partial_range on the underlying container. Reported-by: Mako88 Fixes: 1f434f98ad156bff3303adcd442491f1c9332583 ("Use valptridx for ActiveDoors") --- similar/main/wall.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/similar/main/wall.cpp b/similar/main/wall.cpp index fe946e4a8..3b344ecef 100644 --- a/similar/main/wall.cpp +++ b/similar/main/wall.cpp @@ -1240,14 +1240,14 @@ namespace dsx { void wall_frame_process() { { - const auto &&r = make_range(vactdoorptr); + const auto &&r = partial_range(ActiveDoors, ActiveDoors.get_count()); auto &&i = std::remove_if(r.begin(), r.end(), ad_removal_predicate()); ActiveDoors.set_count(std::distance(r.begin(), i)); } #if defined(DXX_BUILD_DESCENT_II) if (Newdemo_state != ND_STATE_PLAYBACK) { - const auto &&r = make_range(vclwallptr); + const auto &&r = partial_range(CloakingWalls, CloakingWalls.get_count()); cw_removal_predicate rp; std::remove_if(r.begin(), r.end(), std::ref(rp)); CloakingWalls.set_count(rp.num_cloaking_walls);