Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2004:
[Freeciv-Dev] (PR#11357) pubserver crash: ai_unit_move called for unit o
Home

[Freeciv-Dev] (PR#11357) pubserver crash: ai_unit_move called for unit o

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: kaufman@xxxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#11357) pubserver crash: ai_unit_move called for unit of non-ai player
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 8 Dec 2004 19:51:08 -0800
Reply-to: bugs@xxxxxxxxxxx

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

> [cazfi - Mon Dec 06 01:23:29 2004]:
> 
> Mike Kaufman wrote:
> > <URL: http://rt.freeciv.org/Ticket/Display.html?id=11357 >
> > 
> > On Sun, Dec 05, 2004 at 04:45:53PM -0800, Marko Lindqvist wrote:
> > 
> >>   We've got autosettler on city building mission.
> > 
> > for reference, this player had just been aitoggled from ai to human.
> 
>   And unit roles are not reset when player is aitoggled. So settler has 
> kept its previous AIUNIT_BUILD_CITY role. Obviously unit roles should be 
> reseted. Is there any special cases where they should be preserved?
>   Probably also auto_settler_findwork() should be made a bit more 
> secure. It currently believes that if settler has AIUNIT_BUILD_CITY 
> role, it has to be AI player unit. Extra check here can't hurt.

Here's a patch.

-jason

Index: server/settlers.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/settlers.c,v
retrieving revision 1.209.2.1
diff -u -r1.209.2.1 settlers.c
--- server/settlers.c   16 Nov 2004 21:25:42 -0000      1.209.2.1
+++ server/settlers.c   9 Dec 2004 03:50:40 -0000
@@ -1090,10 +1090,14 @@
     struct tile *ptile = punit->goto_tile;
     int sanity = punit->id;
 
-    /* Check that missions is still possible */
-    if (!city_can_be_built_here(ptile, punit)) {
+    /* Check that the mission is still possible.  If the tile has become
+     * unavailable or the player has been autotoggled, call it off. */
+    if (!unit_owner(punit)->ai.control
+       || !city_can_be_built_here(ptile, punit)) {
       UNIT_LOG(LOG_SETTLER, punit, "city founding mission failed");
       ai_unit_new_role(punit, AIUNIT_NONE, NULL);
+      set_unit_activity(punit, ACTIVITY_IDLE);
+      send_unit_info(NULL, punit);
       return; /* avoid recursion at all cost */
     } else {
       /* Go there */

[Prev in Thread] Current Thread [Next in Thread]