Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2002:
[Freeciv-Dev] Re: Map loading error with old saved games (PR#1214)
Home

[Freeciv-Dev] Re: Map loading error with old saved games (PR#1214)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Cc: bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Map loading error with old saved games (PR#1214)
From: jdorje@xxxxxxxxxxxxxxxxxxxxx
Date: Tue, 8 Jan 2002 20:03:45 -0800 (PST)

Vasco Alexandre Da Silva Costa wrote:

I've tried loading a couple of old games on
<ftp://ftp.freeciv.org/pub/freeciv/contrib/development/saved_game>

Like 'capital.sav' and the savegame with 1000 cities 'now.sav' and i get
this:

This is the server for Freeciv version 1.12.1-devel
You can learn a lot about Freeciv at http://www.freeciv.org/
2: Loading saved game: ../capital.sav
2: Loading rulesets
0: Invalid map line for y=0.  This may be a bug in FreeCiv; see
http://www.freeciv.org/ if you think so.

The attached patch should fix this.

The comments in the code explain it all...

jason
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.43
diff -u -r1.43 savegame.c
--- server/savegame.c   2002/01/06 10:35:05     1.43
+++ server/savegame.c   2002/01/09 03:59:22
@@ -107,12 +107,13 @@
  *  - secfile_lookup_line: code which is executed every time a line is
  *  processed; it returns a char* for the line
  */
-/* Note: some of the code this is replacing used to skip over lines
-   that did not exist.  It is unknown whether this was for backwards-
-   compatibility or just because the loops were written differently.
-   This macro will fail if any line does not exist.  Hopefully this
-   will never happen, but if so we at least show an informative
-   message. */
+/* Note: some (but not all) of the code this is replacing used to
+   skip over lines that did not exist.  This allowed for
+   backward-compatibility.  We could add another parameter that
+   specified whether it was OK to skip the data, but there's not
+   really much advantage to exiting early in this case.  Instead,
+   we let any map data type to be empty, and just print an
+   informative warning message about it. */
 #define LOAD_MAP_DATA(secfile_lookup_line, set_xy_char)       \
 {                                                             \
   int y;                                                      \
@@ -120,10 +121,11 @@
     char *line = secfile_lookup_line;                         \
     int x;                                                    \
     if (!line || strlen(line) != map.xsize) {                 \
-      freelog(LOG_FATAL, "Invalid map line for y=%d.  "       \
-             "This may be a bug in FreeCiv; see "            \
-             "http://www.freeciv.org/ if you think so.", y); \
-      exit(1);                                                \
+      freelog(LOG_ERROR, "The save file contains incomplete " \
+              "map data.  This can happen with old saved "    \
+              "games, or it may indicate an invalid saved "   \
+              "game file.  Proceed at your own risk.");       \
+      continue;                                               \
     }                                                         \
     for(x = 0; x < map.xsize; x++) {                          \
       char ch = line[x];                                      \

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