Index: ai/aitools.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/ai/aitools.c,v retrieving revision 1.51 diff -u -r1.51 aitools.c --- ai/aitools.c 2002/08/08 19:22:03 1.51 +++ ai/aitools.c 2002/08/12 22:07:04 @@ -36,8 +36,6 @@ #include "aitools.h" -#define LOG_BODYGUARD LOG_DEBUG - /************************************************************************** Move a bodyguard along with another unit. We assume that unit has already been moved to (x, y) which is a valid, safe coordinate, and that our @@ -59,23 +57,17 @@ assert(punit); if (!is_tiles_adjacent(x, y, bodyguard->x, bodyguard->y)) { - freelog(LOG_BODYGUARD, "%s: %s (%d,%d) is too far from its charge (%d,%d)!", - pplayer->name, unit_type(bodyguard)->name, bodyguard->x, - bodyguard->y, x, y); + BODYGUARD_LOG(bodyguard, "is too far from its charge"); return; } if (bodyguard->moves_left <= 0) { /* should generally should not happen */ - freelog(LOG_BODYGUARD, "%s: %s left its %s bodyguard behind at (%d,%d)!", - pplayer->name, unit_type(punit)->name, - unit_type(bodyguard)->name, x, y); + BODYGUARD_LOG(bodyguard, "was left behind by charge"); return; } - freelog(LOG_BODYGUARD, "%s: Dragging %s's bodyguard %s to (%d,%d)", - pplayer->name, unit_type(punit)->name, unit_type(bodyguard)->name, - x, y); + BODYGUARD_LOG(bodyguard, "was dragged along by charge"); handle_unit_activity_request(bodyguard, ACTIVITY_IDLE); (void) ai_unit_move(bodyguard, x, y); @@ -93,16 +85,13 @@ if (punit->ai.bodyguard > 0) { if ((guard = find_unit_by_id(punit->ai.bodyguard))) { if (guard->ai.charge != punit->id) { - freelog(LOG_BODYGUARD, "%s: %s didn't know it had %s for bodyguard " - "at (%d,%d)!", unit_owner(punit)->name, unit_type(punit)->name, - unit_type(guard)->name, punit->x, punit->y); + BODYGUARD_LOG(guard, "my charge didn't know about me!"); } guard->ai.charge = punit->id; /* ensure sanity */ return TRUE; } else { punit->ai.bodyguard = 0; - freelog(LOG_BODYGUARD, "%s: %s's bodyguard has disappeared at (%d,%d)!", - unit_owner(punit)->name, unit_type(punit)->name, punit->x, punit->y); + UNIT_LOG(punit, "bodyguard disappeared"); } } return FALSE; @@ -169,8 +158,7 @@ && (bodyguard = find_unit_by_id(punit->ai.bodyguard)) && same_pos(punit->x, punit->y, bodyguard->x, bodyguard->y) && bodyguard->moves_left == 0) { - freelog(LOG_BODYGUARD, "%s's %s does not want to leave its %s bodyguard.", - pplayer->name, unit_type(punit)->name, unit_type(bodyguard)->name); + UNIT_LOG(punit, "does not want to leave its bodyguard"); return FALSE; } @@ -179,8 +167,7 @@ && unit_type(punit)->move_rate > map_move_cost(punit, x, y) && enemies_at(punit, x, y) && !enemies_at(punit, punit->x, punit->y)) { - freelog(LOG_DEBUG, "%s's %s ending move early to stay out of trouble.", - pplayer->name, unit_type(punit)->name); + UNIT_LOG(punit, "ending move early to stay out of trouble"); return FALSE; } Index: ai/aitools.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/ai/aitools.h,v retrieving revision 1.20 diff -u -r1.20 aitools.h --- ai/aitools.h 2002/08/08 19:22:03 1.20 +++ ai/aitools.h 2002/08/12 22:07:04 @@ -15,6 +15,26 @@ #include "shared.h" /* bool type */ +#define LOG_BODYGUARD LOG_VERBOSE +#define LOG_UNIT LOG_VERBOSE + +#define UNIT_LOG(punit, msg) \ + freelog(LOG_UNIT, "%s's %s[%d] (%d,%d)->(%d,%d) " ##msg##,\ + unit_owner(punit)->name, unit_type(punit)->name, \ + punit->id, punit->x, punit->y, \ + punit->goto_dest_x, punit->goto_dest_y); + +#define BODYGUARD_LOG(punit, msg) \ +{ \ + struct unit *pcharge = find_unit_by_id(punit->ai.charge); \ + freelog(LOG_BODYGUARD, "%s's bodyguard %s[%d] (%d,%d)[%d@%d,%d]->(%d,%d) " ##msg##,\ + unit_owner(punit)->name, unit_type(punit)->name, \ + punit->id, punit->x, punit->y, \ + pcharge ? pcharge->id : -1, pcharge ? pcharge->x : -1,\ + pcharge ? pcharge->y : -1, \ + punit->goto_dest_x, punit->goto_dest_y); \ +} + struct ai_choice; struct city; struct government; Index: ai/aiunit.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v retrieving revision 1.202 diff -u -r1.202 aiunit.c --- ai/aiunit.c 2002/08/09 11:33:46 1.202 +++ ai/aiunit.c 2002/08/12 22:07:04 @@ -1456,6 +1456,7 @@ /* ok, what if I'm somewhere new? - ugly, kludgy code by Syela */ if (stay_and_defend_city(punit)) { + UNIT_LOG(punit, "stays to defend city"); return; } @@ -2208,7 +2209,7 @@ ai_manage_explorer(punit); break; default: - abort(); + assert(FALSE); } if ((punit = find_unit_by_id(id))) { struct unit_type unit_types[U_LAST]; Index: server/gotohand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/gotohand.c,v retrieving revision 1.146 diff -u -r1.146 gotohand.c --- server/gotohand.c 2002/08/08 19:22:05 1.146 +++ server/gotohand.c 2002/08/12 22:07:06 @@ -1344,6 +1344,7 @@ !(last_tile && trigger_special_ability))) || (pplayer->ai.control && !ai_unit_move(punit, x, y))) { if (punit->moves_left > 0) { + UNIT_LOG(punit, "cancelled goto due to move failure"); punit->activity=ACTIVITY_IDLE; send_unit_info(NULL, punit); return GR_FAILED; @@ -1361,7 +1362,7 @@ } if(punit->x!=x || punit->y!=y) { - freelog(LOG_DEBUG, "Aborting, out of movepoints."); + UNIT_LOG(punit, "aborting, out of movepoints"); send_unit_info(NULL, punit); return GR_OUT_OF_MOVEPOINTS; }