Index: ai/aiunit.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v retrieving revision 1.328 diff -u -r1.328 aiunit.c --- ai/aiunit.c 25 Aug 2004 18:24:18 -0000 1.328 +++ ai/aiunit.c 28 Aug 2004 22:53:36 -0000 @@ -336,15 +336,15 @@ { struct city *pcity = map_get_city(punit->x, punit->y); bool has_defense = FALSE; - - CHECK_UNIT(punit); + int mydef; if (!pcity) { return FALSE; } + mydef = assess_defense_unit(pcity, punit, FALSE); unit_list_iterate(map_get_tile(pcity->x, pcity->y)->units, pdef) { - if (assess_defense_unit(pcity, punit, FALSE) >= 0 + if (assess_defense_unit(pcity, pdef, FALSE) >= mydef && pdef != punit && pdef->homecity == pcity->id) { has_defense = TRUE; @@ -353,12 +353,16 @@ /* Guess I better stay / you can live at home now */ if (!has_defense && pcity->ai.danger > 0) { - /* change homecity to this city */ - if (ai_unit_make_homecity(punit, pcity)) { - /* Very important, or will not stay -- Syela */ - ai_unit_new_role(punit, AIUNIT_DEFEND_HOME, pcity->x, pcity->y); - return TRUE; - } + /* Change homecity to this city */ + (void) ai_unit_make_homecity(punit, pcity); + /* Very important, or will not stay -- Syela */ + ai_unit_new_role(punit, AIUNIT_DEFEND_HOME, pcity->x, pcity->y); + return TRUE; + } + /* Treat grave danger */ + if (pcity->ai.grave_danger > 0) { + ai_unit_new_role(punit, AIUNIT_DEFEND_HOME, pcity->x, pcity->y); + return TRUE; } return FALSE; }