Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2004:
[Freeciv-Dev] Re: (PR#11413) Assertion failed: (id) >= 0 && (id) < game.
Home

[Freeciv-Dev] Re: (PR#11413) Assertion failed: (id) >= 0 && (id) < game.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: brett.albertson@xxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#11413) Assertion failed: (id) >= 0 && (id) < game.num_unit_types, file unittype.c, line 450
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 8 Dec 2004 14:23:01 -0800
Reply-to: bugs@xxxxxxxxxxx

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

Brett Albertson wrote:
> <URL: http://bugs.freeciv.org/Ticket/Display.html?id=11413 >
> 
> I got the following crash playing on CVS HEAD today.
> 
> Assertion failed: (id) >= 0 && (id) < game.num_unit_types, file
> unittype.c, line 450

> This happened during a diplomatic dialog where the AI wanted a
> ceasefire, and I was asking for either a city of a tech.

What was id?

There's a problem with this code in that it checks >= 0 rather than 
U_NOT_OBSOLETED.  This patch fixes it.  But it's surely not the cause of 
the problem since U_NOT_OBSOLETED is -1.

-jason

? client/gui-gtk/citydlg.c.10508
Index: common/aicore/aisupport.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/aisupport.c,v
retrieving revision 1.6
diff -u -r1.6 aisupport.c
--- common/aicore/aisupport.c   8 Dec 2004 16:47:53 -0000       1.6
+++ common/aicore/aisupport.c   8 Dec 2004 22:21:17 -0000
@@ -110,7 +110,7 @@
     if (same_pos(punit->tile, pcity->tile)) {
       Unit_Type_id id = unit_type(punit)->obsoleted_by;
 
-      if (id >= 0 && can_build_unit_direct(pcity, id)) {
+      if (id != U_NOT_OBSOLETED && can_build_unit_direct(pcity, id)) {
         worth += unit_disband_shields(punit->type) / 2; /* obsolete */
       } else {
         worth += unit_disband_shields(punit->type); /* good stuff */

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