<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39564 >
Here is S2_1 version. Trunk version is already committed. This is less critical, as S2_1 does not crash because of the bug. - ML
diff -Nurd -X.diff_ignore freeciv/ai/advdomestic.c freeciv/ai/advdomestic.c --- freeciv/ai/advdomestic.c 2007-08-05 15:36:05.000000000 +0300 +++ freeciv/ai/advdomestic.c 2007-08-14 13:56:21.000000000 +0300 @@ -171,9 +171,8 @@ if (settler_want > 0) { CITY_LOG(LOG_DEBUG, pcity, "desires terrain improvers with passion %d", settler_want); - choice->want = settler_want; - choice->type = CT_NONMIL; - ai_choose_role_unit(pplayer, pcity, choice, F_SETTLERS, settler_want); + ai_choose_role_unit(pplayer, pcity, choice, CT_NONMIL, + F_SETTLERS, settler_want, FALSE); } /* Terrain improvers don't use boats (yet) */ } else if (!settler_type && settler_want > 0) { @@ -205,10 +204,8 @@ if (founder_want > choice->want) { CITY_LOG(LOG_DEBUG, pcity, "desires founders with passion %d", founder_want); - choice->want = founder_want; - choice->need_boat = pcity->ai.founder_boat; - choice->type = CT_NONMIL; - ai_choose_role_unit(pplayer, pcity, choice, F_CITIES, founder_want); + ai_choose_role_unit(pplayer, pcity, choice, CT_NONMIL, + F_CITIES, founder_want, pcity->ai.founder_boat); } else if (founder_want < -choice->want) { /* We need boats to colonize! */ @@ -219,11 +216,17 @@ CITY_LOG(LOG_DEBUG, pcity, "desires founders with passion %d and asks" " for a new boat (%d of %d free)", -founder_want, ai->stats.available_boats, ai->stats.boats); + + /* First fill choice with founder information */ choice->want = 0 - founder_want; choice->type = CT_NONMIL; choice->choice = founder_type->index; /* default */ choice->need_boat = TRUE; - ai_choose_role_unit(pplayer, pcity, choice, L_FERRYBOAT, -founder_want); + + /* Then try to overwrite it with ferryboat information + * If no ferryboat is found, above founder choice stays. */ + ai_choose_role_unit(pplayer, pcity, choice, CT_NONMIL, + L_FERRYBOAT, -founder_want, TRUE); } } else if (!founder_type && (founder_want > choice->want || founder_want < -choice->want)) { diff -Nurd -X.diff_ignore freeciv/ai/advmilitary.c freeciv/ai/advmilitary.c --- freeciv/ai/advmilitary.c 2007-08-04 02:56:41.000000000 +0300 +++ freeciv/ai/advmilitary.c 2007-08-14 13:59:55.000000000 +0300 @@ -1197,7 +1197,8 @@ /* We might need a new boat even if there are boats free, * if they are blockaded or in inland seas*/ assert(is_ground_unit(myunit)); - ai_choose_role_unit(pplayer, pcity, choice, L_FERRYBOAT, choice->want); + ai_choose_role_unit(pplayer, pcity, choice, CT_ATTACKER, + L_FERRYBOAT, choice->want, TRUE); if (SEA_MOVING == utype_by_number(choice->choice)->move_type) { struct ai_data *ai = ai_data_get(pplayer); diff -Nurd -X.diff_ignore freeciv/ai/aitools.c freeciv/ai/aitools.c --- freeciv/ai/aitools.c 2007-08-14 00:28:12.000000000 +0300 +++ freeciv/ai/aitools.c 2007-08-14 13:58:05.000000000 +0300 @@ -1158,14 +1158,23 @@ Calls ai_wants_role_unit to choose the best unit with the given role and set tech wants. Sets choice->choice if we can build something. **************************************************************************/ -void ai_choose_role_unit(struct player *pplayer, struct city *pcity, - struct ai_choice *choice, int role, int want) +bool ai_choose_role_unit(struct player *pplayer, struct city *pcity, + struct ai_choice *choice, enum choice_type type, + int role, int want, bool need_boat) { struct unit_type *iunit = ai_wants_role_unit(pplayer, pcity, role, want); if (iunit != NULL) { + choice->type = type; choice->choice = iunit->index; + choice->want = want; + + choice->need_boat = need_boat; + + return TRUE; } + + return FALSE; } /************************************************************************** diff -Nurd -X.diff_ignore freeciv/ai/aitools.h freeciv/ai/aitools.h --- freeciv/ai/aitools.h 2007-07-04 14:04:26.000000000 +0300 +++ freeciv/ai/aitools.h 2007-08-14 13:58:39.000000000 +0300 @@ -93,8 +93,9 @@ void init_choice(struct ai_choice *choice); void adjust_choice(int value, struct ai_choice *choice); void copy_if_better_choice(struct ai_choice *cur, struct ai_choice *best); -void ai_choose_role_unit(struct player *pplayer, struct city *pcity, - struct ai_choice *choice, int role, int want); +bool ai_choose_role_unit(struct player *pplayer, struct city *pcity, + struct ai_choice *choice, enum choice_type type, + int role, int want, bool need_boat); void ai_advisor_choose_building(struct city *pcity, struct ai_choice *choice); bool ai_assess_military_unhappiness(struct city *pcity, struct government *g);
_______________________________________________ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev