Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2003:
[Freeciv-Dev] Re: (PR#3455) Server crash on save
Home

[Freeciv-Dev] Re: (PR#3455) Server crash on save

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: ChrisK@xxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#3455) Server crash on save
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 17 Feb 2003 04:05:54 -0800
Reply-to: rt@xxxxxxxxxxxxxx

ChrisK@xxxxxxxx wrote:
> CVS 17 FEB 2003
> 
> Maybe related to PR#3454.

Err, well both of them are related to 3013, but probably not to each 
other.  3454 is likely a long-standing bug that only shows up under the 
changes (at least, I hope so).

> Load attached savegame and save.

The bug is easy to find with valgrind.  punit->go is not properly set to 
NULL on load.  I don't know how that one got through testing...

The attached patch also fixes some style with that part (doh!).

jason

Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.112
diff -u -r1.112 savegame.c
--- server/savegame.c   2003/02/17 08:38:36     1.112
+++ server/savegame.c   2003/02/17 12:02:31
@@ -981,18 +981,19 @@
                                                "player%d.u%d.connecting",
                                                plrno, i);
 
-    {
-      /* goto */
-      bool has_goto = secfile_lookup_bool_default(file, TRUE, 
"player%d.u%d.go",
-                                                  plrno, i);
-      if (has_goto) {
-        punit->go = &punit->goto_struct;
-        punit->go->x = secfile_lookup_int(file, 
-                                         "player%d.u%d.goto_x", plrno,i);
-        punit->go->y = secfile_lookup_int(file, 
-                                         "player%d.u%d.goto_y", plrno,i);
-      }
+    /* Load the goto information.  Older savegames will not have the
+     * "go" field, so we just load the goto destination by default. */
+    if (secfile_lookup_bool_default(file, TRUE,
+                                   "player%d.u%d.go", plrno, i)) {
+      punit->go = &punit->goto_struct;
+      punit->go->x = secfile_lookup_int(file,
+                                       "player%d.u%d.goto_x", plrno, i);
+      punit->go->y = secfile_lookup_int(file, 
+                                       "player%d.u%d.goto_y", plrno, i);
+    } else {
+      punit->go = NULL;
     }
+
     punit->ai.control=secfile_lookup_bool(file, "player%d.u%d.ai", plrno,i);
     punit->ai.ai_role = AIUNIT_NONE;
     punit->ai.ferryboat = 0;

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