<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40208 >

 First investigated as 2.1.3 server crash, reproducible with current S2_1:

 - /take AI player who has settlers on city build mission
 - Give new goto-command to settler


 Goto tile will be set to NULL, but ai_unit_new_role() later attempts
to access it in order to cancel city build mission. Proper fix
requires more investigation (and I don't have time just now). Attached
patch is just for avoiding the crash (originally written as test to
check that my analysis of the crash is correct; crash does not happen
when it's applied but error message is printed)


 - ML

diff -Nurd -X.diff_ignore freeciv/ai/aitools.c freeciv/ai/aitools.c
--- freeciv/ai/aitools.c	2008-01-15 04:04:30.000000000 +0200
+++ freeciv/ai/aitools.c	2008-04-21 01:17:30.000000000 +0300
@@ -819,7 +819,12 @@
   }
 
   if (punit->ai.ai_role == AIUNIT_BUILD_CITY) {
-    citymap_free_city_spot(punit->goto_tile, punit->id);
+    if (punit->goto_tile) {
+      citymap_free_city_spot(punit->goto_tile, punit->id);
+    } else {
+      freelog(LOG_ERROR, "%s was on city founding mission without target tile.",
+              unit_rule_name(punit));
+    }
   }
 
   if (punit->ai.ai_role == AIUNIT_HUNTER) {
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to