Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2003:
[Freeciv-Dev] Re: (PR#3546) "Arhus is bugged:" - crash
Home

[Freeciv-Dev] Re: (PR#3546) "Arhus is bugged:" - crash

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: ChrisK@xxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#3546) "Arhus is bugged:" - crash
From: "Raimar Falke" <rf13@xxxxxxxxxxxxxxxxx>
Date: Fri, 28 Feb 2003 05:38:58 -0800
Reply-to: rt@xxxxxxxxxxxxxx

On Fri, Feb 28, 2003 at 03:41:55AM -0800, ChrisK@xxxxxxxx wrote:
> > The savegame is invalid. The size of Århus is 5 and there are indeed 7
> > workers assigned.
> > 
> > Can you reproduce the steps which lead to this savegame?
> 
> Oh man, I love you coders. Can you tell me at least how do I know
> whether a savegame is valid or invalid in this respect?

Sure:

$ zcat power+0360.sav.gz | grep rhus
135,11,22,"Århus",0,5,0,1,0,0,0,0,0,0,10,28,120,13,0,28,0,0,0,0,0,0,17,0,0,15,"2101201010201002200220002",0,13,"00000000000000000000000000000000000001000000000000000000000000000000",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
135,11,22,"Århus",5,0,0
135,11,22,"Århus",5,0,0
135,11,22,"Århus",5,0,0
$

We are interrested in the first line and here the 6th item (size),
8th-10th (elvises, scientists, taxmans) and the citymap (second string
"2101201010201002200220002"). Workers are here marked by "1". But the
central one shouldn't be counted.

  size = elvises + scientists + taxmans + workers
   5   =    1    +     0      +    0    +   (5-1)

So this savegame is correct in this respect.

I can reproduce the problem.

I'm not able to solve it. The problem is that auto_arrange_workers
spends more workers that the city has. With the attached patch you get
an output like:

2: auto_arrange_workers finished
2: auto_arrange_workers for Århus, size=5
2: all workers removed
2: Århus: placing worker at (1, 1)
2: Århus: placing worker at (3, 0)
2: Århus: placing worker at (1, 3)
2: Århus: placing worker at (1, 0)
2: Århus: placing worker at (2, 3)
2: Århus: placing worker at (2, 4)
2: Århus: placing worker at (2, 0)
2: Århus: placing worker at (2, 1)
2: auto_arrange_workers finished
1: Århus is bugged: size:5 workers:7 elvis: 0 tax:0 sci:0

Reason unknown.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Make it idiot-proof and someone will make a better idiot."

Index: server/citytools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v
retrieving revision 1.212
diff -u -u -r1.212 citytools.c
--- server/citytools.c  2003/02/15 15:16:00     1.212
+++ server/citytools.c  2003/02/28 13:37:28
@@ -1989,6 +1989,8 @@
 **************************************************************************/
 void server_set_worker_city(struct city *pcity, int city_x, int city_y)
 {
+  freelog(LOG_NORMAL, "%s: placing worker at (%d, %d)", pcity->name, city_x,
+         city_y);
   assert(is_valid_city_coords(city_x, city_y));
   assert(get_worker_city(pcity, city_x, city_y) == C_TILE_EMPTY);
   server_set_tile_city(pcity, city_x, city_y, C_TILE_WORKER);
Index: server/cityturn.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v
retrieving revision 1.207
diff -u -u -r1.207 cityturn.c
--- server/cityturn.c   2003/02/27 22:15:18     1.207
+++ server/cityturn.c   2003/02/28 13:37:31
@@ -268,11 +268,16 @@
   int taxwanted,sciwanted;
   int foodneed, prodneed;
 
+  freelog(LOG_NORMAL, "auto_arrange_workers for %s, size=%d", pcity->name,
+         pcity->size);
+
   city_map_iterate(x, y) {
     if (get_worker_city(pcity, x, y) == C_TILE_WORKER
        && !is_city_center(x, y))
       server_remove_worker_city(pcity, x, y);
   } city_map_iterate_end;
+
+  freelog(LOG_NORMAL, "all workers removed");
   
   foodneed=(pcity->size *2 -city_get_food_tile(2,2, pcity)) + 
settler_eats(pcity);
   prodneed = 0;
@@ -309,6 +314,8 @@
   }
   pcity->ppl_elvis=workers;
 
+  freelog(LOG_NORMAL, "auto_arrange_workers finished");
+  sanity_check_city(pcity);
   city_refresh(pcity);
 }
 
@@ -428,6 +435,8 @@
 **************************************************************************/
 void city_reduce_size(struct city *pcity, int pop_loss)
 {
+  sanity_check_city(pcity);
+
   if (pcity->size <= pop_loss) {
     remove_city_from_minimap(pcity->x, pcity->y);
     remove_city(pcity);
@@ -460,6 +469,7 @@
     send_city_info(city_owner(pcity), pcity);
   } else {
     auto_arrange_workers(pcity);
+    sanity_check_city(pcity);
     sync_cities();
   }
 }
@@ -1181,6 +1191,7 @@
            "%s is bugged: size:%d workers:%d elvis: %d tax:%d sci:%d",
            pcity->name, size, iswork, pcity->ppl_elvis,
            pcity->ppl_taxman, pcity->ppl_scientist); 
+    assert(0);
     auto_arrange_workers(pcity);
     sync_cities();
   }

[Prev in Thread] Current Thread [Next in Thread]