Skip to content

Commit

Permalink
Added and made use of a move ctor in battle_context
Browse files Browse the repository at this point in the history
(and emplace_back). No reason to use the copy ctor in these cases.
  • Loading branch information
Vultraz committed Apr 25, 2018
1 parent f3a77bf commit 6eab44c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/actions/attack.hpp
Expand Up @@ -189,8 +189,10 @@ class battle_context
battle_context(const battle_context_unit_stats& att, const battle_context_unit_stats& def);

battle_context(const battle_context& other);
battle_context(battle_context&& other) = default;

battle_context& operator=(const battle_context& other);
battle_context& operator=(battle_context&& other) = default;

/** This method returns the statistics of the attacker. */
const battle_context_unit_stats& get_attacker_stats() const
Expand Down
2 changes: 1 addition & 1 deletion src/mouse_events.cpp
Expand Up @@ -955,7 +955,7 @@ int mouse_handler::fill_weapon_choices(
best = bc_vector.size();
}

bc_vector.push_back(bc);
bc_vector.push_back(std::move(bc));
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/reports.cpp
Expand Up @@ -870,8 +870,7 @@ static config unit_weapons(reports::context & rc, const unit *attacker, const ma
for (unsigned int i = 0; i < attacker->attacks().size(); i++) {
// skip weapons with attack_weight=0
if (attacker->attacks()[i].attack_weight() > 0) {
battle_context weapon(rc.units(), attacker_pos, defender->get_location(), i, -1, 0.0, nullptr, attacker);
weapons.push_back(weapon);
weapons.emplace_back(rc.units(), attacker_pos, defender->get_location(), i, -1, 0.0, nullptr, attacker);
}
}

Expand Down

0 comments on commit 6eab44c

Please sign in to comment.