Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2005:
[Freeciv-Dev] (PR#12488) read the tileset toplevel when assembling the l
Home

[Freeciv-Dev] (PR#12488) read the tileset toplevel when assembling the l

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12488) read the tileset toplevel when assembling the list of tilesets
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 11 Mar 2005 11:17:38 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12488 >

When assembling the list of tilesets for the client options dialog, 
currently all *.tilespec files are listed.  What we "should" do is load 
the toplevel of each tileset and make sure it's valid - specifically by 
comparing the capability.

This preliminary patch makes some of the changes necessary for this. 
However it's incomplete because tileset_read_toplevel currently has a 
lot of side effects.

-jason

? vgcore.pid5054
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.265
diff -u -r1.265 tilespec.c
--- client/tilespec.c   11 Mar 2005 17:11:26 -0000      1.265
+++ client/tilespec.c   11 Mar 2005 19:15:50 -0000
@@ -402,15 +402,34 @@
 ***********************************************************************/
 const char **get_tileset_list(void)
 {
-  static const char **tileset_list = NULL;
+  static const char **tilesets = NULL;
 
-  if (!tileset_list) {
+  if (!tilesets) {
     /* Note: this means you must restart the client after installing a new
        tileset. */
-    tileset_list = datafilelist(TILESPEC_SUFFIX);
+    const char **list = datafilelist(TILESPEC_SUFFIX);
+    int i, count = 0;
+
+    for (i = 0; list[i]; i++) {
+      freelog(LOG_NORMAL, "Trying %s.", list[i]);
+
+      struct tileset *t = tileset_read_toplevel(list[i]);
+
+      if (t) {
+       tilesets = fc_realloc(tilesets, (count + 1) * sizeof(*tilesets));
+       tilesets[count] = list[i];
+       count++;
+       tileset_free(t);
+      } else {
+       free(list[i]);
+      }
+    }
+
+    tilesets = fc_realloc(tilesets, (count + 1) * sizeof(*tilesets));
+    tilesets[count] = NULL;
   }
 
-  return tileset_list;
+  return tilesets;
 }
 
 /**********************************************************************
@@ -1202,11 +1221,17 @@
   t->sprite_hash = hash_new(hash_fval_string, hash_fcmp_string);
   for (i = 0; i < num_spec_files; i++) {
     struct specfile *sf = fc_malloc(sizeof(*sf));
+    char *dname;
 
     freelog(LOG_DEBUG, "spec file %s", spec_filenames[i]);
     
     sf->big_sprite = NULL;
-    sf->file_name = mystrdup(datafilename_required(spec_filenames[i]));
+    dname = datafilename(spec_filenames[i]);
+    if (!dname) {
+      tileset_free(t);
+      return NULL;
+    }
+    sf->file_name = mystrdup(dname);
     scan_specfile(t, sf, duplicates_ok);
 
     specfile_list_prepend(t->specfiles, sf);
Index: utility/shared.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/utility/shared.c,v
retrieving revision 1.125
diff -u -r1.125 shared.c
--- utility/shared.c    8 Mar 2005 18:54:45 -0000       1.125
+++ utility/shared.c    11 Mar 2005 19:15:50 -0000
@@ -1180,7 +1180,7 @@
     freelog(LOG_ERROR, _("Current data path is: \"%s\""), datafilename(NULL));
     freelog(LOG_FATAL,
                 _("The \"%s\" file is required ... aborting!"), filename);
-    exit(EXIT_FAILURE);
+    abort();
   }
 }
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12488) read the tileset toplevel when assembling the list of tilesets, Jason Short <=