wb: fix moves for planned recruits
the for those moves get_unit() might return nullptr when it is when the future map is not applied and some codes deduced from that that the action is invalid. So we make sure that code does not rely on get_unit().
This commit is contained in:
parent
576bdea529
commit
0745eb94a3
4 changed files with 12 additions and 7 deletions
|
@ -73,7 +73,7 @@ public:
|
|||
* Returns the id of the unit targeted by this action.
|
||||
* @retval 0 no unit is targeted.
|
||||
*/
|
||||
size_t get_unit_id() const;
|
||||
virtual size_t get_unit_id() const;
|
||||
|
||||
/** @return pointer to the fake unit used only for visuals */
|
||||
virtual fake_unit_ptr get_fake_unit() = 0;
|
||||
|
|
|
@ -190,6 +190,9 @@ void highlighter::last_action_redraw(move_ptr move)
|
|||
if(move->get_fake_unit()) {
|
||||
side_actions& sa = *resources::gameboard->teams().at(move->team_index()).get_side_actions().get();
|
||||
|
||||
#if 0
|
||||
// Disabled this since for moves of planned recruits get_unit() returns nullptr, een tough they are still valid.
|
||||
|
||||
// Units with planned actions may have been killed in the previous turn before all actions were completed.
|
||||
// In these cases, remove these planned actions for any invalid units and do not redraw anything.
|
||||
if (move->get_unit() == nullptr)
|
||||
|
@ -204,8 +207,8 @@ void highlighter::last_action_redraw(move_ptr move)
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
side_actions::iterator last_action = sa.find_last_action_of(*(move->get_unit()));
|
||||
#endif
|
||||
side_actions::iterator last_action = sa.find_last_action_of(move->get_unit_id());
|
||||
side_actions::iterator second_to_last_action = last_action != sa.end() && last_action != sa.begin() ? last_action - 1 : sa.end();
|
||||
|
||||
bool this_is_last_action = last_action != sa.end() && move == *last_action;
|
||||
|
@ -256,7 +259,7 @@ void highlighter::find_secondary_highlights()
|
|||
action_ptr highlighter::get_execute_target()
|
||||
{
|
||||
if(action_ptr locked = selected_action_.lock()) {
|
||||
return *side_actions_->find_first_action_of(*(locked->get_unit()));
|
||||
return *side_actions_->find_first_action_of(locked->get_unit_id());
|
||||
} else {
|
||||
return action_ptr();
|
||||
}
|
||||
|
@ -264,7 +267,7 @@ action_ptr highlighter::get_execute_target()
|
|||
action_ptr highlighter::get_delete_target()
|
||||
{
|
||||
if(action_ptr locked = selected_action_.lock()) {
|
||||
return *side_actions_->find_last_action_of(*(locked->get_unit()));
|
||||
return *side_actions_->find_last_action_of(locked->get_unit_id());
|
||||
} else {
|
||||
return action_ptr();
|
||||
}
|
||||
|
|
|
@ -535,8 +535,9 @@ void manager::pre_draw()
|
|||
|
||||
for (size_t unit_id : units_owning_moves_) {
|
||||
unit_map::iterator unit_iter = resources::gameboard->units().find(unit_id);
|
||||
assert(unit_iter.valid());
|
||||
ghost_owner_unit(&*unit_iter);
|
||||
if(unit_iter.valid()) {
|
||||
ghost_owner_unit(&*unit_iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ public:
|
|||
|
||||
/** Return the unit targeted by this action. Null if unit doesn't exist. */
|
||||
virtual unit_ptr get_unit() const;
|
||||
virtual size_t get_unit_id() const { return unit_underlying_id_; }
|
||||
/** @return pointer to the fake unit used only for visuals */
|
||||
virtual fake_unit_ptr get_fake_unit() { return fake_unit_; }
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue