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

Jason Dorje Short wrote:
> The CM code is in common/aicore/cm.c.
Well, I've spent a bit of time looking at that, and its pretty difficult.
Whomever wrote that was a genius, or an idiot....

Anyway, using the old tried and true pedestrian debugging techniques, I've
found one very nasty place that this happens: IN THE SANITY CHECK!!!

Somebody felt the need to do more than check, without any message or
indication to the user!

In server/sanitycheck.c real_sanity_check_city():

   if (workers + city_specialists(pcity) != pcity->size + 1) {
     int diff = pcity->size + 1 - workers - city_specialists(pcity);

     SANITY_CITY(pcity, workers + city_specialists(pcity) == pcity->size + 1);

       if (diff < 0) {
        city_map_checked_iterate(pcity->tile, city_x, city_y, ptile) {
          if (ptile->worked == pcity && diff < 0) {
            server_remove_worker_city(pcity, city_x, city_y);
        } city_map_checked_iterate_end;

The first worker found is the city center!

Now, I still don't know how the dickens the city size is bad, but the
cure is worse than the disease!!!!


Other server_remove_worker_city() calls elsewhere have a check before them,
for example:

       if (!is_valid || is_free_worked_tile(city_map_x, city_map_y)) {
        /* Can't remove a worker here. */
       server_remove_worker_city(acity, city_map_x, city_map_y);


This is called often -- sanitycheck needs a thorough cleaning.  And all
these error messages need to be sent to the client.  Currently, there's no
easy way for them to be seen during the game.

Freeciv-dev mailing list

Reply via email to