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

As of revision 12589 of trunk, the ai never builds harbours.

The reason for this is that  the call to is_req_active() in 
adjust_wants_for_reqs() returns false when called with "pimpr=harbour", 
regardless of whether the requirements for building a harbour are satisfied 
or not.

This is in turn caused by setting the fourth argument of is_req_active() to 
NULL, which makes the call to is_terrain_in_range() in is_req_active() return 
false. In other words, the check if the city borders on the ocean always 
fails.

An easy fix is to supply pcity->tile instead of NULL as argument to 
is_req_active(). This makes the ai build harbours in a sensible way and 
(apparently) doesn't break anything in the ai's behaviour. But since I'm 
pretty new to freeciv's code, I am not sure whether this is the "right" 
solution. In any case, there's a (very trivial) patch attached.


Frank

--- aicity.c.orig	2007-02-02 10:43:04.000000000 +0100
+++ aicity.c	2007-02-02 10:43:49.000000000 +0100
@@ -647,7 +647,7 @@
 
   requirement_vector_iterate(&pimpr->reqs, preq) {
     const bool active = is_req_active(pplayer, pcity, pimpr,
-                                      NULL, NULL, NULL, NULL, preq);
+                                      pcity->tile, NULL, NULL, NULL, preq);
     if (preq->source.type == REQ_TECH && !active) {
       /* Found a missing technology requirement for this improvement. */
       tech_vector_append(&needed_techs, &preq->source.value.tech);
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to