Skip to content

Commit

Permalink
Don't construct an intrusive pointer from a raw pointer
Browse files Browse the repository at this point in the history
@gfgtdf is worried about the possibility of this code being called from a unit's constructor, which would create problems.
  • Loading branch information
CelticMinstrel committed Mar 4, 2018
1 parent 96f69a3 commit 6b4aef9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/units/abilities.cpp
Expand Up @@ -45,7 +45,7 @@ namespace {
class temporary_facing
{
map_location::DIRECTION save_dir_;
unit_const_ptr u_;
const unit* u_;
public:
temporary_facing(const unit* u, map_location::DIRECTION new_dir)
: save_dir_(u ? u->facing() : map_location::NDIRECTIONS)
Expand Down Expand Up @@ -949,8 +949,8 @@ bool attack_type::special_active(const config& special, AFFECTS whom,
assert(display::get_singleton());
const unit_map& units = display::get_singleton()->get_units();

const unit* self = self_.get();
const unit* other = other_.get();
const unit* self = self_;
const unit* other = other_;

if(self == nullptr) {
unit_map::const_iterator it = units.find(self_loc_);
Expand Down
3 changes: 2 additions & 1 deletion src/units/attack_type.hpp
Expand Up @@ -109,7 +109,8 @@ class attack_type : public std::enable_shared_from_this<attack_type>
// Used via set_specials_context() to control which specials are
// considered active.
mutable map_location self_loc_, other_loc_;
mutable unit_const_ptr self_, other_;
mutable const unit* self_;
mutable const unit* other_;
mutable bool is_attacker_;
mutable const_attack_ptr other_attack_;
mutable bool is_for_listing_ = false;
Expand Down

0 comments on commit 6b4aef9

Please sign in to comment.