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

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

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [freeciv-ai] (PR#10567) Re: pubserver crash: ai-controlled unit has no goto destination
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Mon, 18 Oct 2004 06:11:05 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=10567 >

Here is a patch to turn the assert into a freelog (hopefully).

  - Per
Index: ai/aidiplomat.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aidiplomat.c,v
retrieving revision 1.40
diff -u -r1.40 aidiplomat.c
--- ai/aidiplomat.c     29 Sep 2004 02:24:18 -0000      1.40
+++ ai/aidiplomat.c     18 Oct 2004 13:10:07 -0000
@@ -624,7 +624,7 @@
     } else if ((ctarget = ai_diplomat_defend(pplayer, punit,
                                              punit->type, map)) != NULL) {
       task = AIUNIT_DEFEND_HOME;
-      UNIT_LOG(LOG_DIPLOMAT, punit, "going defensive");
+      UNIT_LOG(LOG_DIPLOMAT, punit, "going to defend %s", ctarget->name);
     } else if ((ctarget = find_closest_owned_city(pplayer, punit->tile, 
                                                  TRUE, NULL)) != NULL) {
       /* This should only happen if the entire continent was suddenly
@@ -639,10 +639,16 @@
     }
 
     ai_unit_new_role(punit, task, ctarget->tile);
+    assert(punit->moves_left > 0 && ctarget 
+           && punit->ai.ai_role != AIUNIT_NONE);
   }
 
   CHECK_UNIT(punit);
-  assert(punit->moves_left > 0 && ctarget && punit->ai.ai_role != AIUNIT_NONE);
+  if (ctarget == NULL) {
+    UNIT_LOG(LOG_ERROR, punit, "ctarget not set (role==%d)", 
punit->ai.ai_role);
+    pf_destroy_map(map);
+    return;
+  }
 
   /* GOTO unless we want to stay */
   if (!same_pos(punit->tile, ctarget->tile)) {

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