Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2003:
[Freeciv-Dev] (PR#4732) worklists get saved full of garbage
Home

[Freeciv-Dev] (PR#4732) worklists get saved full of garbage

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#4732) worklists get saved full of garbage
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 31 Jul 2003 21:51:32 -0700
Reply-to: rt@xxxxxxxxxxxxxx

If you use a worklist, the unused values (after the end of the wl) can 
get filled with garbage.  If you then save the game garbage will be 
saved.  But if you reload it the garbage will of course be ignored.  The 
result is ugly but not harmful.

To see this in action, use a worklist and save your game.  Then reload 
the game and immediately save it again.  The savegames will differ.

jason

Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.127
diff -u -r1.127 savegame.c
--- server/savegame.c   2003/07/23 13:46:04     1.127
+++ server/savegame.c   2003/08/01 04:50:18
@@ -1307,6 +1307,16 @@
   for (i = 0; i < MAX_LEN_WORKLIST; i++) {
     secfile_insert_int(file, pwl->wlefs[i], efpath, plrno, wlinx, i);
     secfile_insert_int(file, pwl->wlids[i], idpath, plrno, wlinx, i);
+    if (pwl->wlefs[i] == WEF_END) {
+      break;
+    }
+  }
+
+  /* Fill out remaining worklist entries. */
+  for (; i < MAX_LEN_WORKLIST; i++) {
+    /* These values match what worklist_load fills in for unused entries. */
+    secfile_insert_int(file, WEF_END, efpath, plrno, wlinx, i);
+    secfile_insert_int(file, 0, idpath, plrno, wlinx, i);
   }
 }
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#4732) worklists get saved full of garbage, Jason Short <=