Project

General

Profile

Bug #586 ยป 0034-Make-dying-unit-to-correctly-triggger-auto-turn-done.patch

Marko Lindqvist, 05/11/2024 07:17 PM

View differences:

client/climisc.c
game_remove_unit(&wld, punit);
punit = NULL;
if (old > 0 && get_num_units_in_focus() == 0) {
unit_focus_advance();
unit_focus_advance(TRUE);
} else if (update) {
update_unit_pix_label(get_units_in_focus());
update_unit_info_label(get_units_in_focus());
client/control.c
goto_unit_killed(punit);
if (unit_is_in_focus(punit)
&& get_num_units_in_focus() == 1) {
unit_focus_advance(FALSE);
}
unit_list_remove(get_units_in_focus(), punit);
if (get_num_units_in_focus() < 1) {
clear_hover_state();
......
**************************************************************************/
void unit_focus_remove(struct unit *punit)
{
bool keep_in_focus = FALSE;
if (NULL != punit
&& NULL != client.conn.playing
&& unit_owner(punit) != client.conn.playing) {
......
clear_hover_state();
}
current_focus_remove(punit);
if (get_num_units_in_focus() > 0) {
focus_units_changed();
} else {
unit_focus_advance();
if (get_num_units_in_focus() == 1) {
unit_focus_advance(TRUE);
if (unit_is_in_focus(punit)) {
/* Unit was restored to focus (there was no other units to focus to) */
keep_in_focus = TRUE;
}
}
if (!keep_in_focus) {
current_focus_remove(punit);
if (get_num_units_in_focus() > 0) {
focus_units_changed();
}
}
}
......
called when user press the "Wait" command.
FIXME: Add feature to focus only units of a certain category.
@param accept_current The current focus can be kept if no other candidates
**************************************************************************/
void unit_focus_advance(void)
void unit_focus_advance(bool accept_current)
{
struct unit *candidate = NULL;
const int num_units_in_old_focus = get_num_units_in_focus();
......
unit_list_iterate(get_units_in_focus(), punit) {
/*
* Is the unit which just lost focus a non-AI unit? If yes this
* enables the auto end turn.
* enables the auto end turn.
*/
if (punit->ssa_controller == SSA_NONE) {
non_ai_unit_focus = TRUE;
......
} unit_list_iterate_end;
candidate = find_best_focus_candidate(FALSE);
if (!candidate) {
if (!candidate && accept_current) {
/* Accept current focus unit as last resort. */
candidate = find_best_focus_candidate(TRUE);
}
......
}
} unit_list_iterate_end;
unit_focus_advance();
unit_focus_advance(TRUE);
}
/**********************************************************************//**
......
punit->client.focus_status = FOCUS_WAIT;
} unit_list_iterate_end;
if (punits == get_units_in_focus()) {
unit_focus_advance();
unit_focus_advance(TRUE);
}
}
......
punit->client.focus_status = new_status;
} unit_list_iterate_end;
if (new_status == FOCUS_DONE) {
unit_focus_advance();
unit_focus_advance(TRUE);
}
}
}
client/control.h
void unit_focus_remove(struct unit *punit);
void unit_focus_urgent(struct unit *punit);
void unit_focus_advance(void);
void unit_focus_advance(bool accept_current);
void unit_focus_update(void);
void auto_center_on_focus_unit(void);
    (1-1/1)