[Freeciv-Dev] Re: (PR#10567) pubserver crash: ai-controlled unit has no
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] Re: (PR#10567) pubserver crash: ai-controlled unit has no goto destination |
From: |
"Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx> |
Date: |
Sat, 16 Oct 2004 14:51:31 -0700 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=10567 >
The role is ATTACK or DEFEND_HOME, but there is no goto destination set.
So there's a crash.
Does this mean the unit has arrived? For instance with DEFEND_HOME once
we get there isn't the goto_dest cleared? In this case should we be
looking at the current tile? Or should we not have cleared the goto
dest? Or is a special case needed for DEFEND_HOME?
This patch avoids the crash but may still be buggy. If the goto dest is
null it's treated as the success case. However this may mean a unit can
get locked into this role. I dunno.
jason
? fctest
? freeciv-2.0.0-beta1.tar.gz
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 16 Oct 2004 21:48:27 -0000
@@ -574,7 +574,12 @@
|| punit->ai.ai_role == AIUNIT_DEFEND_HOME) {
bool failure = FALSE;
- ctarget = map_get_city(punit->goto_tile);
+ /* In rare cases the goto tile may be NULL at this point. It's
+ * probably a bug... */
+#ifdef DEBUG
+ assert(punit->goto_tile != NULL);
+#endif
+ ctarget = punit->goto_tile ? punit->goto_tile->city : NULL;
if (pf_get_position(map, punit->goto_tile, &pos)
&& ctarget) {
if (same_pos(ctarget->tile, punit->tile)) {
- [Freeciv-Dev] Re: (PR#10567) pubserver crash: ai-controlled unit has no goto destination,
Jason Short <=
|
|