wb: fix future unit sprite missing

fixes #2124
This commit is contained in:
gfgtdf 2018-04-30 17:44:36 +02:00 committed by Charles Dang
parent c19590fc45
commit 9277a6cf53
6 changed files with 21 additions and 11 deletions

View file

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

View file

@ -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.

View file

@ -54,7 +54,7 @@ std::ostream& attack::print(std::ostream& s) const
attack::attack(std::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()),

View file

@ -773,7 +773,6 @@ void manager::save_temp_move()
continue;
std::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
@ -781,7 +780,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();
@ -802,7 +801,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())
@ -811,12 +810,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
{
@ -834,7 +833,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();

View file

@ -71,7 +71,7 @@ move::move(std::size_t team_index, bool hidden, unit& u, const pathfind::marked_
movement_cost_(0),
turn_number_(0),
arrow_(arrow),
fake_unit_(fake_unit),
fake_unit_(std::move(fake_unit)),
arrow_brightness_(),
arrow_texture_(),
mover_(),

View file

@ -673,13 +673,13 @@ side_actions::iterator side_actions::safe_erase(const iterator& itor)
}
side_actions::iterator side_actions::queue_move(std::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(std::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);
}