Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2004:
[Freeciv-Dev] (PR#11410) bug in city gold eval function
Home

[Freeciv-Dev] (PR#11410) bug in city gold eval function

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#11410) bug in city gold eval function
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Wed, 8 Dec 2004 08:14:26 -0800
Reply-to: rt@xxxxxxxxxxx

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

This fixes a serious bug in the AI gold eval function for cities, that
leads to crashes, if obsoleted_by is -1 (no obsoletion).

  - Per

Index: common/aicore/aisupport.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/aisupport.c,v
retrieving revision 1.5
diff -u -r1.5 aisupport.c
--- common/aicore/aisupport.c   29 Sep 2004 02:24:23 -0000      1.5
+++ common/aicore/aisupport.c   8 Dec 2004 16:03:43 -0000
@@ -108,7 +108,9 @@
   worth = pcity->size * 150; /* reasonable base cost */
   unit_list_iterate(pcity->units_supported, punit) {
     if (same_pos(punit->tile, pcity->tile)) {
-      if (can_build_unit_direct(pcity, unit_type(punit)->obsoleted_by)) {
+      Unit_Type_id id = unit_type(punit)->obsoleted_by;
+
+      if (id >= 0 && 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]
  • [Freeciv-Dev] (PR#11410) bug in city gold eval function, Per I. Mathisen <=