Index: common/tech.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/tech.c,v retrieving revision 1.49 diff -u -r1.49 tech.c --- common/tech.c 2002/08/07 11:21:48 1.49 +++ common/tech.c 2002/10/10 13:23:42 @@ -221,11 +221,19 @@ **************************************************************************/ Tech_Type_id get_next_tech(struct player *pplayer, Tech_Type_id goal) { + Tech_Type_id result; + if (goal == A_NONE || !tech_exists(goal) || get_invention(pplayer, goal) == TECH_KNOWN) { return A_NONE; } - return (get_next_tech_rec(pplayer, goal)); + + result = get_next_tech_rec(pplayer, goal); + if(result != A_NONE) { + assert(get_invention(pplayer, result) == TECH_REACHABLE); + } + + return result; } /************************************************************************** Index: server/plrhand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/plrhand.c,v retrieving revision 1.246 diff -u -r1.246 plrhand.c --- server/plrhand.c 2002/10/09 14:10:17 1.246 +++ server/plrhand.c 2002/10/10 13:23:43 @@ -55,6 +55,8 @@ struct player *receiver, enum plr_info_level min_info_level); +static bool choose_goal_tech(struct player *plr); + /************************************************************************** ... **************************************************************************/ @@ -270,7 +272,7 @@ int saved_bulbs = plr->research.bulbs_researched; - if (choose_goal_tech(plr) != 0) { + if (choose_goal_tech(plr)) { notify_player_ex(plr, -1, -1, E_TECH_LEARNED, _("Game: Learned %s. " "Our scientists focus on %s, goal is %s."), @@ -304,6 +306,9 @@ } } + assert(is_future_tech(plr->research.researching) || + get_invention(plr, plr->research.researching) == TECH_REACHABLE); + if (bonus_tech_hack) { if (advances[tech_found].bonus_message) { notify_player(plr, _("Game: %s"), @@ -417,11 +422,13 @@ } /************************************************************************** -... + Choose the next tech leading to ai.tech_goal and set it in + research.researching if found. Update ai.tech_goal if + required. Return FALSE if no tech could be found. **************************************************************************/ -int choose_goal_tech(struct player *plr) +static bool choose_goal_tech(struct player *plr) { - int sub_goal; + Tech_Type_id sub_goal; if (plr->research.bulbs_researched > 0) { plr->research.bulbs_researched = 0; @@ -429,8 +436,10 @@ if (plr->ai.control) { ai_next_tech_goal(plr); /* tech-AI has been changed */ sub_goal = get_next_tech(plr, plr->ai.tech_goal); /* should be changed */ - } else sub_goal = get_next_tech(plr, plr->ai.tech_goal); - if (sub_goal == 0) { + } else { + sub_goal = get_next_tech(plr, plr->ai.tech_goal); + } + if (sub_goal == A_NONE) { if (plr->ai.control || plr->research.techs_researched == 1) { ai_next_tech_goal(plr); sub_goal = get_next_tech(plr, plr->ai.tech_goal); @@ -439,10 +448,10 @@ } } - if (sub_goal != 0) { - plr->research.researching=sub_goal; + if (sub_goal != A_NONE) { + plr->research.researching = sub_goal; } - return sub_goal; + return sub_goal != A_NONE; } Index: server/plrhand.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/plrhand.h,v retrieving revision 1.50 diff -u -r1.50 plrhand.h --- server/plrhand.h 2002/10/09 20:54:20 1.50 +++ server/plrhand.h 2002/10/10 13:23:43 @@ -78,7 +78,6 @@ void choose_random_tech(struct player *plr); void choose_tech(struct player *plr, int tech); void choose_tech_goal(struct player *plr, int tech); -int choose_goal_tech(struct player *plr); void get_a_tech(struct player *pplayer, struct player *target); void send_player_turn_notifications(struct conn_list *dest);