parent
55065e10d4
commit
edb4d2cf04
6 changed files with 21 additions and 11 deletions
|
@ -26,7 +26,17 @@ fake_unit_ptr::fake_unit_ptr(const internal_ptr & u, fake_unit_manager * mgr) :
|
|||
{
|
||||
place_on_fake_unit_manager(mgr);
|
||||
}
|
||||
fake_unit_ptr::fake_unit_ptr(const fake_unit_ptr & ptr) : unit_(ptr.unit_), my_manager_(nullptr) {}
|
||||
fake_unit_ptr::fake_unit_ptr(const fake_unit_ptr & ptr)
|
||||
: unit_(ptr.unit_)
|
||||
, my_manager_(nullptr)
|
||||
{}
|
||||
|
||||
fake_unit_ptr::fake_unit_ptr(fake_unit_ptr && ptr)
|
||||
: unit_(std::move(ptr.unit_))
|
||||
, my_manager_(ptr.my_manager_)
|
||||
{
|
||||
ptr.my_manager_ = nullptr;
|
||||
}
|
||||
|
||||
void fake_unit_ptr::swap (fake_unit_ptr & o) {
|
||||
boost::swap(unit_, o.unit_);
|
||||
|
|
|
@ -37,6 +37,7 @@ public:
|
|||
explicit fake_unit_ptr(const internal_ptr & u); //!< Construct a fake unit pointer wrapping a normal unit pointer, marking it as a fake unit.
|
||||
fake_unit_ptr(const internal_ptr & u, fake_unit_manager * mgr); //!< Construct a fake unit pointer, and simultaenously register with a manager.
|
||||
fake_unit_ptr(const fake_unit_ptr & ptr); //!< Copy construct a fake unit pointer. Does not reallocate the underlying unit.
|
||||
fake_unit_ptr(fake_unit_ptr && ptr);
|
||||
|
||||
void swap (fake_unit_ptr & o); //!< Pointer swap.
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ std::ostream& attack::print(std::ostream& s) const
|
|||
|
||||
attack::attack(size_t team_index, bool hidden, unit& u, const map_location& target_hex, int weapon_choice, const pathfind::marked_route& route,
|
||||
arrow_ptr arrow, fake_unit_ptr fake_unit)
|
||||
: move(team_index, hidden, u, route, arrow, fake_unit),
|
||||
: move(team_index, hidden, u, route, arrow, std::move(fake_unit)),
|
||||
target_hex_(target_hex),
|
||||
weapon_choice_(weapon_choice),
|
||||
attack_movement_cost_(get_unit()->attacks()[weapon_choice_].movement_used()),
|
||||
|
|
|
@ -782,7 +782,6 @@ void manager::save_temp_move()
|
|||
continue;
|
||||
|
||||
size_t turn = first_turn + i;
|
||||
fake_unit_ptr fake_unit = fake_units_[i];
|
||||
|
||||
//@todo Using a marked_route here is wrong, since right now it's not marked
|
||||
//either switch over to a plain route for planned moves, or mark it correctly
|
||||
|
@ -790,7 +789,7 @@ void manager::save_temp_move()
|
|||
route.steps = move_arrow->get_path();
|
||||
route.move_cost = path_cost(route.steps,*u);
|
||||
|
||||
sa.queue_move(turn,*u,route,move_arrow,fake_unit);
|
||||
sa.queue_move(turn, *u, route, move_arrow, std::move(fake_units_[i]));
|
||||
}
|
||||
erase_temp_move();
|
||||
|
||||
|
@ -811,7 +810,7 @@ void manager::save_temp_attack(const map_location& attacker_loc, const map_locat
|
|||
assert(weapon_choice >= 0);
|
||||
|
||||
arrow_ptr move_arrow;
|
||||
fake_unit_ptr fake_unit;
|
||||
fake_unit_ptr* fake_unit = nullptr;
|
||||
map_location source_hex;
|
||||
|
||||
if (route_ && !route_->steps.empty())
|
||||
|
@ -820,12 +819,12 @@ void manager::save_temp_attack(const map_location& attacker_loc, const map_locat
|
|||
assert(move_arrows_.size() == 1);
|
||||
assert(fake_units_.size() == 1);
|
||||
move_arrow = move_arrows_.front();
|
||||
fake_unit = fake_units_.front();
|
||||
fake_unit = &fake_units_.front();
|
||||
|
||||
assert(route_->steps.back() == attacker_loc);
|
||||
source_hex = route_->steps.front();
|
||||
|
||||
fake_unit->anim_comp().set_disabled_ghosted(true);
|
||||
(**fake_unit).anim_comp().set_disabled_ghosted(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -843,7 +842,7 @@ void manager::save_temp_attack(const map_location& attacker_loc, const map_locat
|
|||
validate_viewer_actions();
|
||||
|
||||
side_actions& sa = *viewer_actions();
|
||||
sa.queue_attack(sa.get_turn_num_of(*attacking_unit),*attacking_unit,defender_loc,weapon_choice,*route_,move_arrow,fake_unit);
|
||||
sa.queue_attack(sa.get_turn_num_of(*attacking_unit), *attacking_unit, defender_loc, weapon_choice, *route_, move_arrow, fake_unit ? std::move(*fake_unit) : fake_unit_ptr());
|
||||
|
||||
print_help_once();
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ move::move(size_t team_index, bool hidden, unit& u, const pathfind::marked_route
|
|||
movement_cost_(0),
|
||||
turn_number_(0),
|
||||
arrow_(arrow),
|
||||
fake_unit_(fake_unit),
|
||||
fake_unit_(std::move(fake_unit)),
|
||||
arrow_brightness_(),
|
||||
arrow_texture_(),
|
||||
mover_(),
|
||||
|
|
|
@ -674,13 +674,13 @@ side_actions::iterator side_actions::safe_erase(const iterator& itor)
|
|||
}
|
||||
side_actions::iterator side_actions::queue_move(size_t turn, unit& mover, const pathfind::marked_route& route, arrow_ptr arrow, fake_unit_ptr fake_unit)
|
||||
{
|
||||
move_ptr new_move(std::make_shared<move>(team_index(), hidden_, std::ref(mover), route, arrow, fake_unit));
|
||||
move_ptr new_move(std::make_shared<move>(team_index(), hidden_, std::ref(mover), route, arrow, std::move(fake_unit)));
|
||||
return queue_action(turn, new_move);
|
||||
}
|
||||
|
||||
side_actions::iterator side_actions::queue_attack(size_t turn, unit& mover, const map_location& target_hex, int weapon_choice, const pathfind::marked_route& route, arrow_ptr arrow, fake_unit_ptr fake_unit)
|
||||
{
|
||||
attack_ptr new_attack(std::make_shared<attack>(team_index(), hidden_, std::ref(mover), target_hex, weapon_choice, route, arrow, fake_unit));
|
||||
attack_ptr new_attack(std::make_shared<attack>(team_index(), hidden_, std::ref(mover), target_hex, weapon_choice, route, arrow, std::move(fake_unit)));
|
||||
return queue_action(turn, new_attack);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue