Skip to content

Commit

Permalink
Fix failure to remove expired walls
Browse files Browse the repository at this point in the history
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 <#283>
Fixes: 1f434f9 ("Use valptridx for ActiveDoors")
  • Loading branch information
vLKp committed Dec 11, 2016
1 parent 656d087 commit 4a01fab
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions similar/main/wall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4a01fab

Please sign in to comment.