[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]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12488 >
> [jdorje - Fri Mar 11 19:17:36 2005]:
>
> 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.
Many of these side effects have been removed. This patch is a
much-improved (but still not complete) version.
-jason
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.285
diff -u -r1.285 tilespec.c
--- client/tilespec.c 6 Apr 2005 17:36:14 -0000 1.285
+++ client/tilespec.c 8 Apr 2005 06:15:47 -0000
@@ -378,7 +378,7 @@
struct tileset *tileset;
-#define TILESPEC_CAPSTR "+tilespec3 duplicates_ok"
+#define TILESPEC_CAPSTR "+tilespec3 duplicates_ok +Freeciv.Devel.2005.Apr.8"
/*
* Tilespec capabilities acceptable to this program:
*
@@ -635,15 +635,33 @@
***********************************************************************/
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++) {
+ 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);
+ freelog(LOG_NORMAL, "Adding %s", list[i]);
+ } else {
+
+ }
+ }
+
+ tilesets = fc_realloc(tilesets, (count + 1) * sizeof(*tilesets));
+ tilesets[count] = NULL;
}
- return tileset_list;
+ return tilesets;
}
/**********************************************************************
@@ -705,7 +723,7 @@
char *file_capstr = secfile_lookup_str(file, "%s.options", which);
if (!has_capabilities(us_capstr, file_capstr)) {
- freelog(LOG_ERROR, _("%s file appears incompatible:\n"
+ freelog(LOG_DEBUG, _("%s file appears incompatible:\n"
"file: \"%s\"\n"
"file options: %s\n"
"supported options: %s"),
@@ -713,7 +731,7 @@
return FALSE;
}
if (!has_capabilities(file_capstr, us_capstr)) {
- freelog(LOG_ERROR, _("%s file claims required option(s)"
+ freelog(LOG_DEBUG, _("%s file claims required option(s)"
" which we don't support:\n"
"file: \"%s\"\n"
"file options: %s\n"
@@ -1142,7 +1160,6 @@
enum direction8 dir;
struct tileset *t = tileset_new();
- tileset = t; /* HACK: because some functions still use the global value. */
fname = tilespec_fullname(tileset_name);
freelog(LOG_VERBOSE, "tilespec file is %s", fname);
@@ -1443,11 +1460,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: data/isophex.tilespec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/isophex.tilespec,v
retrieving revision 1.12
diff -u -r1.12 isophex.tilespec
--- data/isophex.tilespec 18 Mar 2005 00:38:55 -0000 1.12
+++ data/isophex.tilespec 8 Apr 2005 06:15:47 -0000
@@ -2,7 +2,7 @@
[tilespec]
; Format and options of this tilespec file:
-options = "+tilespec3"
+options = "+tilespec3 +Freeciv.Devel.2005.Apr.8"
; A simple name for the tileset specified by this file:
name = "isophex"
Index: data/isotrident.tilespec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/isotrident.tilespec,v
retrieving revision 1.35
diff -u -r1.35 isotrident.tilespec
--- data/isotrident.tilespec 18 Mar 2005 00:38:55 -0000 1.35
+++ data/isotrident.tilespec 8 Apr 2005 06:15:47 -0000
@@ -2,7 +2,7 @@
[tilespec]
; Format and options of this tilespec file:
-options = "+tilespec3"
+options = "+tilespec3 +Freeciv.Devel.2005.Apr.8"
; A simple name for the tileset specified by this file:
name = "MacroIsoTrident"
Index: data/trident.tilespec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/trident.tilespec,v
retrieving revision 1.35
diff -u -r1.35 trident.tilespec
--- data/trident.tilespec 18 Mar 2005 00:38:55 -0000 1.35
+++ data/trident.tilespec 8 Apr 2005 06:15:47 -0000
@@ -2,7 +2,7 @@
[tilespec]
; Format and options of this tilespec file:
-options = "+tilespec3"
+options = "+tilespec3 +Freeciv.Devel.2005.Apr.8"
; A simple name for the tileset specified by this file:
name = "Trident"
Index: data/trident_shields.tilespec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/trident_shields.tilespec,v
retrieving revision 1.26
diff -u -r1.26 trident_shields.tilespec
--- data/trident_shields.tilespec 18 Mar 2005 00:38:55 -0000 1.26
+++ data/trident_shields.tilespec 8 Apr 2005 06:15:47 -0000
@@ -2,7 +2,7 @@
[tilespec]
; Format and options of this tilespec file:
-options = "+tilespec3 +duplicates_ok"
+options = "+tilespec3 +duplicates_ok +Freeciv.Devel.2005.Apr.8"
; A simple name for the tileset specified by this file:
name = "Trident w/Shields"
- [Freeciv-Dev] (PR#12488) read the tileset toplevel when assembling the list of tilesets,
Jason Short <=
|
|