Complete.Org: Mailing Lists: Archives: freeciv-ai: November 2004:
[freeciv-ai] (PR#10567) pubserver crash: ai-controlled unit has no goto

[freeciv-ai] (PR#10567) pubserver crash: ai-controlled unit has no goto

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [freeciv-ai] (PR#10567) pubserver crash: ai-controlled unit has no goto destination
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 15 Nov 2004 10:00:17 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: >

Now I can reproduce this bug!

Load the attached savegame.  The player is on ai-mode but you should
connect with a client.  Hit "turn done" and all the diplomats will be
given an ai role.  Then put one of the diplomats that is en route onto a
short goto.  Hit turn done again.  When the goto completes the goto_tile
will be cleared, leaving a unit that still has an AI role requiring a
goto tile but no longer has a goto tile.

In the long term we should things so that only the AI uses goto_tile. 
However this may be a bit tricky.  I think orders don't have to use
goto_tile anymore (this was needed when they were first written, but
since fixed).  However client-side air goto does need goto_tile.  Even
if orders are fixed it's possible that there will still be a crash if
client-side "server goto" is used.  As long as this value is used for
multiple things it will always be bug-prone.

In the short term I think we just need to get rid of the role when the
unit is given orders.  This patch should do this (AI people should make
sure this is the right way to do it).


Index: server/unithand.c
RCS file: /home/freeciv/CVS/freeciv/server/unithand.c,v
retrieving revision 1.310
diff -u -r1.310 unithand.c
--- server/unithand.c   10 Nov 2004 17:02:00 -0000      1.310
+++ server/unithand.c   15 Nov 2004 17:59:30 -0000
@@ -1628,6 +1628,10 @@
+  if (punit->ai.ai_role != AIUNIT_NONE) {
+    ai_unit_new_role(punit, AIUNIT_NONE, NULL);
+  }
   punit->has_orders = TRUE;
   punit->orders.length = packet->length;
   punit->orders.index = 0;

[Prev in Thread] Current Thread [Next in Thread]
  • [freeciv-ai] (PR#10567) pubserver crash: ai-controlled unit has no goto destination, Jason Short <=