Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2006:
[Freeciv-Dev] (PR#18220) [Patch] Fix ai_choose_help_wonder() crash
Home

[Freeciv-Dev] (PR#18220) [Patch] Fix ai_choose_help_wonder() crash

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#18220) [Patch] Fix ai_choose_help_wonder() crash
From: "Marko Lindqvist" <marko.lindqvist@xxxxxxxxxxx>
Date: Sat, 1 Jul 2006 08:09:24 -0700
Reply-to: bugs@xxxxxxxxxxx

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


  ai_wants_role_unit() returns NULL if city cannot yet build unit. This 
may crash ai_choose_help_wonder().
  Fix attached.


  - ML


diff -Nurd -X.diff_ignore freeciv/ai/advdomestic.c freeciv/ai/advdomestic.c
--- freeciv/ai/advdomestic.c    2006-06-30 20:33:15.671875000 +0300
+++ freeciv/ai/advdomestic.c    2006-07-01 18:03:51.671875000 +0300
@@ -118,13 +118,13 @@
       /* This sets our tech want in cases where we cannot actually build
        * the unit. */
       unit_type = ai_wants_role_unit(pplayer, pcity, F_HELP_WONDER, want);
-      if (can_build_unit(pcity, unit_type)) {
+      if (unit_type != NULL) {
         choice->want = want;
         choice->type = CT_NONMIL;
         choice->choice = unit_type->index;
       } else {
-        CITY_LOG(LOG_DEBUG, pcity, "would but could not build %s, bumped reqs",
-                 unit_name(unit_type));
+        CITY_LOG(LOG_DEBUG, pcity,
+                 "would but could not build F_HELP_WONDER unit, bumped reqs");
       }
     }
   }

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#18220) [Patch] Fix ai_choose_help_wonder() crash, Marko Lindqvist <=