Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2000:
[Freeciv-Dev] worklist bug crashes client (patch)
Home

[Freeciv-Dev] worklist bug crashes client (patch)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] worklist bug crashes client (patch)
From: John-Marc Chandonia <jmc@xxxxxxxxxxxxxxxx>
Date: Tue, 8 Feb 2000 23:59:21 -0800

There is currently a problem with uninitialized items in worklists,
which sometimes causes the client to crash.  The last item in
a worklist is supposed to be marked with WORKLIST_END (284), but
in certain circumstances (which I haven't figured out) the uninitialized
integers after the last item in the worklist can sometimes get ahead
of the WORKPLACE_END marker.  Here is an example line from a saved
game, which crashes the client when you pop up the city's worklist:

164,54,13,"Tiberias",0,1,0,0,0,0,0,0,0,0,19,0,0,-725,-725,0,0,0,0,0,15,"2000200000001000001022002",0,16,"00000000000000000000000000000000000000000000000000000000000000000000",15,13,20,2,1,11,17,18,25,16,15,13,20,2,15792,284

The fix is to properly initialize the worklist, both when creating
it (which is not necessary to fix this bug, but still a good idea)
and when committing changes made from the dialog.  Here is a patch
which fixes the gtk version; the bug might still exist in other versions.
Check your saved game for uninitialized worklist items to make sure
the bug does not exist for other clients.

These are diffs against the latest CVS:

--- ../../freeciv/common/worklist.c     Tue Feb  8 23:38:13 2000
+++ worklist.c  Tue Feb  8 23:38:58 2000
@@ -28,7 +28,10 @@
 }
   
 void init_worklist(struct worklist *pwl) {
-  pwl->ids[0] = WORKLIST_END;
+  int i;
+
+  for (i=0; i<MAX_LEN_WORKLIST; i++) 
+      pwl->ids[i] = WORKLIST_END;
   pwl->is_valid = 1;
   strcpy(pwl->name, "a worklist");
 }
--- ../../../freeciv/client/gui-gtk/citydlg.c   Tue Feb  8 23:38:13 2000
+++ citydlg.c   Tue Feb  8 23:33:50 2000
@@ -1862,6 +1862,7 @@
   for (i = 0; i < MAX_LEN_WORKLIST-1; i++) {
     packet.worklist.ids[i] = pwl->ids[i];
   }
+  packet.worklist.ids[MAX_LEN_WORKLIST-1] = WORKLIST_END;
     
   send_packet_city_request(&aconnection, &packet, PACKET_CITY_WORKLIST);
 
JMC
-- 
John-Marc Chandonia (jmc@xxxxxxxxxxxxxxxx)              We're everywhere...
Cohen Lab, University of California San Francisco       for your convenience.
http://yuri.harvard.edu/~jmc                                -- Psi Corps <*>


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