Don't update constriction when testing door seals
authorEdgar A. Bering IV <trizor@gmail.com>
Thu, 14 Jan 2021 17:44:25 +0000 (19:44 +0200)
committerEdgar A. Bering IV <trizor@gmail.com>
Thu, 14 Jan 2021 17:44:25 +0000 (19:44 +0200)
The vault warden AI check to see if it should seal a door
was using move_to_pos to evaluate the tension of actor moves, but
move_to_pos handles updating constriction information of the
constrictor. The result was that if the check needed to test if pushing
something through a door in a way that would break constriction was a
good idea, the constriction would actually break, even if the monster
ultimately decided to not close the door!

Closes #1566

crawl-ref/source/mon-cast.cc

index de2fd5b..471d5d8 100644 (file)
@@ -2172,9 +2172,9 @@ static vector<coord_def> _get_push_spaces_max_tension(const coord_def& pos,
         find_connected_identical(pos, all_door);
         dungeon_feature_type old_feat = env.grid(pos);
 
-        act->move_to_pos(c);
+        act->set_position(c);
         int new_tension = _tension_door_closed(all_door, old_feat);
-        act->move_to_pos(pos);
+        act->set_position(pos);
 
         if (new_tension == max_tension)
             best.push_back(c);
@@ -2224,13 +2224,13 @@ static bool _should_force_door_shut(const coord_def& door)
     {
         coord_def newpos =
                 _get_push_spaces_max_tension(you.pos(), &veto_spots).front();
-        you.move_to_pos(newpos);
+        you.set_position(newpos);
     }
 
     const int new_tension = _tension_door_closed(all_door, old_feat);
 
     if (player_in_door)
-        you.move_to_pos(oldpos);
+        you.set_position(oldpos);
 
     dprf("Considering sealing cur tension: %d, new tension: %d",
          cur_tension, new_tension);