Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2002:
[Freeciv-Dev] Re: CMA failed assertion caused by Freight (PR#1684)
Home

[Freeciv-Dev] Re: CMA failed assertion caused by Freight (PR#1684)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: kenn@xxxxxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: CMA failed assertion caused by Freight (PR#1684)
From: "Raimar Falke via RT" <rt@xxxxxxxxxxxxxx>
Date: Mon, 18 Nov 2002 03:37:27 -0800
Reply-to: rt@xxxxxxxxxxxxxx

On Sat, Sep 14, 2002 at 05:48:14PM +0200, Raimar Falke wrote:
> On Wed, Jul 10, 2002 at 06:13:14PM +0200, Raimar Falke wrote:
> > On Mon, Jul 08, 2002 at 09:02:47PM -0700, kenn@xxxxxxxxxxxxxx wrote:
> > > Full_Name: Kenn Munro
> > > Version: 1.12.7-devel
> > > Distribution: Built from source
> > > Client: Gtk+
> > > OS: Red Hat 7.2
> > > Submission from: (NULL) (216.104.96.132)
> > > 
> > > 
> > > When moving a freight into one of my own cities, I get the message:
> > > 
> > > 1: CMA: Tampere has changed multiple times. This may be an error in 
> > > freeciv or
> > > bad luck. Please contact <freeciv-dev@xxxxxxxxxxx>. The CMA will detach 
> > > itself
> > > from the city now.
> > > civclient: cma_core.c:1795: handle_city: Assertion `0' failed.
> > > Aborted (core dumped)
> > > 
> > > I've uploaded a savegame (kenn12.sav.gz) to incoming.  Join as kenn, then 
> > > move
> > > the freight from Zephath to Tampere.
> > > 
> > > Zephath had produced a number of freights in previous turns, which were 
> > > used for
> > > trade routes.  Some of those freights had also been assigned to different 
> > > home
> > > cities.
> > 
> > This is a nasty one: the freight moves and makes a tile to Oulu
> > unavailable and later available again. The worker is removed the first
> > time and isn't put to work the second time. First problem: Oulu isn't
> > recalulated the second time. Second problem: the client isn't informed
> > about this. However if the unit arrives at Tampere the server also
> > recalculates Oulu which now have a worker less (than the current info
> > of the client) causing reduces trade which causes reduces trade from
> > trade route which causes a mismatch between server and client.
> 
> > There is IMHO no easy fix and recalculating the cities at the server
> > (which will be part of the fix) will make the server slower. So since
> > it uncommon and not critical I would vote for post-release.
> 
> And the patch. AI-people please comment on the use of
> auto_arrange_workers.

And the patch with fewer calls to auto_arrange_workers as requested by
Per.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Programming today is a race between software engineers striving to
  build bigger and better idiot-proof programs, and the Universe trying
  to produce bigger and better idiots. So far, the Universe is winning."
    -- Rich Cook

? 1684_fix1.diff
? 1684_fix2.diff
? a
? a.c
? a.s
? city_turns_to_grow-2.diff
? city_turns_to_grow-3.diff
? civscore.log
? die1.diff
? diff
? genlist1.diff
? include_fix1.diff
? log
? packet_size1.diff
? test.c
? warnings_A_1.diff
? xaw_bug1.gif
Index: server/citytools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v
retrieving revision 1.196
diff -u -r1.196 citytools.c
--- server/citytools.c  2002/11/14 09:22:10     1.196
+++ server/citytools.c  2002/11/18 11:34:21
@@ -1973,18 +1973,20 @@
 }
 
 /**************************************************************************
-Wrapper.
-You need to call sync_cities for the affected cities to be synced with the
-client.
+Wrapper (using map positions) for update_city_tile_status (which uses
+city map positions).
+
+You need to call sync_cities for the affected cities to be synced with
+the client.
 **************************************************************************/
-void update_city_tile_status_map(struct city *pcity, int map_x, int map_y)
+bool update_city_tile_status_map(struct city *pcity, int map_x, int map_y)
 {
   int city_x, city_y;
   bool is_valid;
 
   is_valid = map_to_city_map(&city_x, &city_y, pcity, map_x, map_y);
   assert(is_valid);
-  update_city_tile_status(pcity, city_x, city_y);
+  return update_city_tile_status(pcity, city_x, city_y);
 }
 
 /**************************************************************************
@@ -1992,11 +1994,14 @@
 city_x, city_y is in city map coords.
 You need to call sync_cities for the affected cities to be synced with the
 client.
+
+Returns TRUE iff a tile got available.
 **************************************************************************/
-void update_city_tile_status(struct city *pcity, int city_x, int city_y)
+bool update_city_tile_status(struct city *pcity, int city_x, int city_y)
 {
   enum city_tile_type current;
   bool is_available;
+  bool result = FALSE;
 
   assert(is_valid_city_coords(city_x, city_y));
 
@@ -2009,12 +2014,14 @@
       server_set_tile_city(pcity, city_x, city_y, C_TILE_UNAVAILABLE);
       add_adjust_workers(pcity); /* will place the displaced */
       city_refresh(pcity);
+      send_city_info(NULL, pcity);
     }
     break;
 
   case C_TILE_UNAVAILABLE:
     if (is_available) {
       server_set_tile_city(pcity, city_x, city_y, C_TILE_EMPTY);
+      result = TRUE;
     }
     break;
 
@@ -2024,6 +2031,8 @@
     }
     break;
   }
+
+  return result;
 }
 
 /**************************************************************************
Index: server/citytools.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.h,v
retrieving revision 1.41
diff -u -r1.41 citytools.h
--- server/citytools.h  2002/08/14 00:01:57     1.41
+++ server/citytools.h  2002/11/18 11:34:22
@@ -90,8 +90,8 @@
 bool city_can_work_tile(struct city *pcity, int city_x, int city_y);
 void server_remove_worker_city(struct city *pcity, int city_x, int city_y);
 void server_set_worker_city(struct city *pcity, int city_x, int city_y);
-void update_city_tile_status_map(struct city *pcity, int map_x, int map_y);
-void update_city_tile_status(struct city *pcity, int city_x, int city_y);
+bool update_city_tile_status_map(struct city *pcity, int map_x, int map_y);
+bool update_city_tile_status(struct city *pcity, int city_x, int city_y);
 void sync_cities(void);
 bool can_place_worker_here(struct city *pcity, int city_x, int city_y);
 void check_city_workers(struct player *pplayer);
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.195
diff -u -r1.195 unittools.c
--- server/unittools.c  2002/11/14 09:15:05     1.195
+++ server/unittools.c  2002/11/18 11:34:28
@@ -2908,15 +2908,18 @@
   /* First check cities near the source. */
   map_city_radius_iterate(src_x, src_y, x1, y1) {
     struct city *pcity = map_get_city(x1, y1);
-    if (pcity) {
-      update_city_tile_status_map(pcity, src_x, src_y);
+
+    if (pcity && update_city_tile_status_map(pcity, src_x, src_y)) {
+      auto_arrange_workers(pcity);
+      send_city_info(NULL, pcity);
     }
   } map_city_radius_iterate_end;
   /* Then check cities near the destination. */
   map_city_radius_iterate(dest_x, dest_y, x1, y1) {
     struct city *pcity = map_get_city(x1, y1);
-    if (pcity) {
-      update_city_tile_status_map(pcity, dest_x, dest_y);
+    if (pcity && update_city_tile_status_map(pcity, dest_x, dest_y)) {
+      auto_arrange_workers(pcity);
+      send_city_info(NULL, pcity);
     }
   } map_city_radius_iterate_end;
   sync_cities();

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Re: CMA failed assertion caused by Freight (PR#1684), Raimar Falke via RT <=