mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-21 14:34:53 +00:00
Refactoring in preparation to fix bug #19222
This commit is contained in:
parent
cd1222a879
commit
5e819ce7b8
@ -315,6 +315,25 @@ void manager::pre_delete_action(action_ptr action)
|
||||
}
|
||||
}
|
||||
|
||||
void manager::post_delete_action(action_ptr action)
|
||||
{
|
||||
// The ghost of the last fake unit in a chain of planned actions is supposed to look different
|
||||
// If the last remaining action of the unit that owned this move is a move as well,
|
||||
// adjust its appearance accordingly.
|
||||
|
||||
side_actions_ptr side_actions = resources::teams->at(action->team_index()).get_side_actions();
|
||||
|
||||
side_actions::iterator action_it = side_actions->find_last_action_of(action->get_unit());
|
||||
if (action_it != side_actions->end())
|
||||
{
|
||||
if (move_ptr move = boost::dynamic_pointer_cast<class move>(*action_it))
|
||||
{
|
||||
if (move->get_fake_unit())
|
||||
move->get_fake_unit()->set_ghosted(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void hide_all_plans()
|
||||
{
|
||||
foreach(team& t, *resources::teams)
|
||||
|
@ -95,7 +95,10 @@ public:
|
||||
void on_gamestate_change();
|
||||
void on_viewer_change(size_t team_index);
|
||||
void on_change_controller(int side, team& t);
|
||||
void pre_delete_action(action_ptr action); //< Handles various cleanup right before deleting an action
|
||||
/** Handles various cleanup right before removing an action from the queue */
|
||||
void pre_delete_action(action_ptr action);
|
||||
/** Handles various cleanup right after removing an action from the queue */
|
||||
void post_delete_action(action_ptr action);
|
||||
|
||||
/** Called by replay_network_sender to add whiteboard data to the outgoing network packets */
|
||||
void send_network_data();
|
||||
|
@ -186,31 +186,6 @@ void move::init()
|
||||
}
|
||||
}
|
||||
|
||||
move::~move()
|
||||
{
|
||||
// The ghost of the last fake unit in a chain of planned actions is supposed to look different
|
||||
// If the last remaining action of the unit that owned this move is a move as well,
|
||||
// adjust its appearance accordingly.
|
||||
if (resources::teams)
|
||||
{
|
||||
side_actions_ptr side_actions = resources::teams->at(team_index()).get_side_actions();
|
||||
|
||||
side_actions::iterator action_it = side_actions->find_last_action_of(unit_);
|
||||
if (action_it != side_actions->end())
|
||||
{
|
||||
if (move_ptr move = boost::dynamic_pointer_cast<class move>(*action_it))
|
||||
{
|
||||
if (move->fake_unit_)
|
||||
move->fake_unit_->set_ghosted(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//reminder: here we rely on the ~arrow destructor to invalidate
|
||||
//its whole path.
|
||||
}
|
||||
|
||||
void move::accept(visitor& v)
|
||||
{
|
||||
v.visit(shared_from_this());
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
move(size_t team_index, bool hidden, unit& mover, const pathfind::marked_route& route,
|
||||
arrow_ptr arrow, fake_unit_ptr fake_unit);
|
||||
move(config const&, bool hidden); // For deserialization
|
||||
virtual ~move();
|
||||
virtual ~move(){}
|
||||
|
||||
virtual std::ostream& print(std::ostream& s) const;
|
||||
|
||||
|
@ -678,7 +678,9 @@ side_actions::iterator side_actions::safe_erase(iterator const& itor)
|
||||
{
|
||||
action_ptr action = *itor;
|
||||
resources::whiteboard->pre_delete_action(action); //misc cleanup
|
||||
return raw_erase(itor);
|
||||
iterator return_itor = raw_erase(itor);
|
||||
resources::whiteboard->post_delete_action(action);
|
||||
return return_itor;
|
||||
}
|
||||
|
||||
void side_actions::execute_net_cmd(net_cmd const& cmd)
|
||||
|
Loading…
x
Reference in New Issue
Block a user