diff -uNrX freeciv/diff_ignore freeciv/ai/aiunit.c freeciv-ai/ai/aiunit.c --- freeciv/ai/aiunit.c 2002-08-13 01:01:46.000000000 +0200 +++ freeciv-ai/ai/aiunit.c 2002-08-13 00:56:17.000000000 +0200 @@ -617,10 +617,9 @@ /* Guess I better stay / you can live at home now */ if (!has_defense) { struct packet_unit_request packet; - punit->ai.ai_role = AIUNIT_DEFEND_HOME; /* Very important, or will not stay -- Syela */ - punit->ai.charge = BODYGUARD_NONE; + ai_unit_new_role(punit, AIUNIT_DEFEND_HOME); /* change homecity to this city */ /* FIXME: it is stupid to change homecity if the unit has no homecity @@ -1095,7 +1094,7 @@ y = acity->y; } else { /* should be impossible */ - punit->ai.charge = BODYGUARD_NONE; + ai_unit_new_role(punit, AIUNIT_NONE); return; } @@ -1113,7 +1112,7 @@ do_unit_goto(punit, GOTO_MOVE_ANY, FALSE); } else { /* can't possibly get there to help */ - punit->ai.charge = BODYGUARD_NONE; + ai_unit_new_role(punit, AIUNIT_NONE); } } else { /* I had these guys set to just fortify, which is so dumb. -- Syela */ @@ -1250,7 +1249,7 @@ } else if (!unit_list_find(&ptile->units, punit->ai.bodyguard)) punit->ai.bodyguard = BODYGUARD_NONE; - if( is_barbarian(pplayer) ) /* barbarians must have more currage */ + if (is_barbarian(pplayer)) /* barbarians must have more courage */ punit->ai.bodyguard = BODYGUARD_NONE; /* end protection subroutine */ @@ -1356,7 +1355,7 @@ assert(player_find_unit_by_id(pplayer, id) != NULL); /* in case we need to change */ - punit->ai.ai_role = AIUNIT_NONE; + punit->ai.ai_role = AIUNIT_NONE; /* this can't be right -- Per */ if (x != punit->x || y != punit->y) { return 1; /* moved */ @@ -1481,9 +1480,11 @@ unit_vulnerability_virtual(aunit)) || (acity && acity->owner == punit->owner && acity->ai.urgency != 0 && acity->ai.danger > assess_defense_quadratic(acity))) { - punit->ai.ai_role = AIUNIT_ESCORT; + punit->ai.ai_role = AIUNIT_ESCORT; /* do not use ai_unit_new_role() */ return; - } else punit->ai.charge = BODYGUARD_NONE; + } else { + ai_unit_new_role(punit, AIUNIT_NONE); + } } /* ok, what if I'm somewhere new? - ugly, kludgy code by Syela */ @@ -1524,13 +1525,13 @@ } /* this is bad; riflemen might rather attack if val is low -- Syela */ if (acity) { - punit->ai.ai_role = AIUNIT_ESCORT; + ai_unit_new_role(punit, AIUNIT_ESCORT); punit->ai.charge = acity->id; freelog(LOG_DEBUG, "%s@(%d, %d) going to defend %s@(%d, %d)", unit_type(punit)->name, punit->x, punit->y, acity->name, acity->x, acity->y); } else if (aunit) { - punit->ai.ai_role = AIUNIT_ESCORT; + ai_unit_new_role(punit, AIUNIT_ESCORT); punit->ai.charge = aunit->id; freelog(LOG_DEBUG, "%s@(%d, %d) going to defend %s@(%d, %d)", unit_type(punit)->name, punit->x, punit->y, @@ -1538,7 +1539,9 @@ } else if (unit_attack_desirability(punit->type) != 0 || (pcity && !same_pos(pcity->x, pcity->y, punit->x, punit->y))) punit->ai.ai_role = AIUNIT_ATTACK; - else punit->ai.ai_role = AIUNIT_DEFEND_HOME; /* for default */ + else { + ai_unit_new_role(punit, AIUNIT_DEFEND_HOME); /* for default */ + } } /**********************************************************************