Complete.Org: Mailing Lists: Archives: freeciv-ai: December 2002:
[freeciv-ai] bug in ai_military_findvictim
Home

[freeciv-ai] bug in ai_military_findvictim

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv ai <freeciv-ai@xxxxxxxxxxx>
Subject: [freeciv-ai] bug in ai_military_findvictim
From: Jordi Negrevernis i Font <jorneg@xxxxxxxxxxx>
Date: Fri, 06 Dec 2002 17:51:07 +0100


   When patt is Null the function crashes...

   Here is a patch that resolves it.

   I don't know if it's the best solution but at least it doesn't crash.


--- aiunit.c.orig       Wed Nov 27 18:26:54 2002
+++ aiunit.c    Fri Dec  6 14:08:27 2002
@@ -980,7 +980,12 @@
       /* FIXME: The get_total_defense_power(pdef, punit) should probably use
        * patt rather than pdef. There also ought to be a better metric for
        * determining this. */
-      if (map_get_city(x, y) && get_total_defense_power(pdef, punit) *
+      if (!patt) {
+        freelog(LOG_DEBUG, "%s's %s defending %s from %s's %s at (%d, %d)",
+                pplayer->name, unit_type(punit)->name, map_get_city(x, 
y)->name,
+                unit_owner(pdef)->name, unit_type(pdef)->name, punit->x, 
punit->y);
+      }
+      else if (map_get_city(x, y) && get_total_defense_power(pdef, punit) *
                                 get_total_defense_power(punit, pdef) >=
                                 get_total_attack_power(patt, punit) *
                                 get_total_attack_power(punit, pdef)

[Prev in Thread] Current Thread [Next in Thread]
  • [freeciv-ai] bug in ai_military_findvictim, Jordi Negrevernis i Font <=