[Freeciv-Dev] Re: (PR#15408) ai_select_tech can return A_UNSET in choice
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=15408 >
a better patch which deals with an error condition.
-mike
Index: ai/aitech.c
===================================================================
--- ai/aitech.c (revision 11503)
+++ ai/aitech.c (working copy)
@@ -69,6 +69,22 @@
goal_values[A_UNSET] = -1;
goal_values[A_NONE] = -1;
+ /* if we are researching future techs, then simply continue with that.
+ * we don't need to do anything below. */
+ if (is_future_tech(get_player_research(pplayer)->researching)) {
+ if (choice) {
+ choice->choice = get_player_research(pplayer)->researching;
+ choice->want = 1;
+ choice->current_want = 1;
+ }
+ if (goal) {
+ goal->choice = get_player_research(pplayer)->tech_goal;
+ goal->want = 1;
+ goal->current_want = 1;
+ }
+ return;
+ }
+
/* Fill in values for the techs: want of the tech
* + average want of those we will discover en route */
tech_type_iterate(i) {
@@ -157,6 +173,13 @@
goal_values[newgoal],
num_cities_nonzero);
}
+
+ /* we can't have this, which will happen in the circumstance
+ * where all ai.tech_wants are negative */
+ if (choice && choice->choice == A_UNSET) {
+ choice->choice = get_player_research(pplayer)->researching;
+ }
+
return;
}
|
|