Added and made use of a move ctor in battle_context
(and emplace_back). No reason to use the copy ctor in these cases.
(cherry-picked from commit 6eab44c4f3
)
This commit is contained in:
parent
5cac72b91f
commit
8e323e8f6e
3 changed files with 4 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -962,7 +962,7 @@ int mouse_handler::fill_weapon_choices(
|
|||
best = bc_vector.size();
|
||||
}
|
||||
|
||||
bc_vector.push_back(bc);
|
||||
bc_vector.push_back(std::move(bc));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue