diff --git a/client/climisc.c b/client/climisc.c index b4af1574c3..f441cc0b13 100644 --- a/client/climisc.c +++ b/client/climisc.c @@ -93,6 +93,10 @@ void client_remove_unit(struct unit *punit) } unit_list_iterate_end; } + log_normal("BEGINS"); + log_normal("client_remove_unit() %p at (%d, %d)", punit, TILE_XY(ptile)); + log_normal("client_remove_unit(): %d units in focus.", + get_num_units_in_focus()); control_unit_killed(punit); game_remove_unit(&wld, punit); punit = NULL; @@ -102,6 +106,7 @@ void client_remove_unit(struct unit *punit) update_unit_pix_label(get_units_in_focus()); update_unit_info_label(get_units_in_focus()); } + log_normal("ENDS"); pcity = tile_city(ptile); if (NULL != pcity) { diff --git a/client/control.c b/client/control.c index 675755c63d..4156a030ef 100644 --- a/client/control.c +++ b/client/control.c @@ -242,6 +242,9 @@ void control_unit_killed(struct unit *punit) } focus_units_changed(); + + log_normal("End of control_unit_killed(): %d units in focus.", + get_num_units_in_focus()); } /**********************************************************************//** @@ -635,11 +638,15 @@ static struct unit *find_best_focus_candidate(bool accept_current) { struct tile *ptile = get_center_tile_mapcanvas(); + log_normal("Center tile: (%d, %d)", TILE_XY(ptile)); + if (!get_focus_unit_on_tile(ptile)) { struct unit *pfirst = head_of_units_in_focus(); if (pfirst) { ptile = unit_tile(pfirst); + + log_normal("focus head tile: (%d, %d)", TILE_XY(ptile)); } } @@ -693,12 +700,21 @@ void unit_focus_advance(void) } } unit_list_iterate_end; + log_normal("unit_focus_advance(): urgent focus size %d", + unit_list_size(urgent_focus_queue)); + if (unit_list_size(urgent_focus_queue) > 0) { /* Try top of the urgent list. */ struct tile *focus_tile = (get_num_units_in_focus() > 0 ? unit_tile(head_of_units_in_focus()) : NULL); + if (focus_tile != NULL) { + log_normal("urgent focus tile: (%d, %d)", TILE_XY(focus_tile)); + } else { + log_normal("urgent focus tile NULL"); + } + unit_list_both_iterate(urgent_focus_queue, plink, punit) { if ((ACTIVITY_IDLE != punit->activity || unit_has_orders(punit)) @@ -711,9 +727,11 @@ void unit_focus_advance(void) || focus_tile == unit_tile(punit)) { /* Use the first one found */ candidate = punit; + log_normal("focus tile candidate: %p", candidate); break; } else if (NULL == candidate) { candidate = punit; + log_normal("first candidate: %p", candidate); } } unit_list_both_iterate_end; @@ -731,6 +749,8 @@ void unit_focus_advance(void) if (NULL == candidate) { candidate = find_best_focus_candidate(FALSE); + log_normal("best focus candidate: %p", candidate); + if (!candidate) { /* Try for "waiting" units. */ unit_list_iterate(client.conn.playing->units, punit) { @@ -740,9 +760,13 @@ void unit_focus_advance(void) } unit_list_iterate_end; candidate = find_best_focus_candidate(FALSE); + log_normal("best waiting candidate: %p", candidate); + if (!candidate) { /* Accept current focus unit as last resort. */ candidate = find_best_focus_candidate(TRUE); + + log_normal("best candidate, considering current: %p", candidate); } } }