Added and made use of a move ctor in battle_context

(and emplace_back). No reason to use the copy ctor in these cases.
This commit is contained in:
Charles Dang 2018-04-25 15:45:52 +11:00
parent f3a77bf310
commit 6eab44c4f3
3 changed files with 4 additions and 3 deletions

View file

@ -189,8 +189,10 @@ public:
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

View file

@ -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));
}
}

View file

@ -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);
}
}