[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.
And here's another updated patch. Some more of the side effects have
been removed so those changes are no longer needed in the patch.
However the default_tileset_name has to be set outside of
tileset_fullname so this requires some new changes. This behavior can
be much improved.
However this patch is probably ready as it is.
-jason
Index: client/civclient.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/civclient.c,v
retrieving revision 1.218
diff -u -r1.218 civclient.c
--- client/civclient.c 14 Mar 2005 21:37:09 -0000 1.218
+++ client/civclient.c 13 Apr 2005 06:31:48 -0000
@@ -345,6 +345,7 @@
/* get tile sizes etc */
exit(EXIT_FAILURE);
}
+ sz_strlcpy(default_tileset_name, tileset_get_name(tileset));
audio_real_init(sound_set_name, sound_plugin_name);
audio_play_music("music_start", NULL);
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.291
diff -u -r1.291 tilespec.c
--- client/tilespec.c 13 Apr 2005 02:21:51 -0000 1.291
+++ client/tilespec.c 13 Apr 2005 06:31:50 -0000
@@ -382,7 +382,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:
*
@@ -409,6 +409,14 @@
/****************************************************************************
+ Return the name of the tileset.
+****************************************************************************/
+const char *tileset_get_name(const struct tileset *t)
+{
+ return t->name;
+}
+
+/****************************************************************************
Return whether the current tileset is isometric.
****************************************************************************/
bool tileset_is_isometric(const struct tileset *t)
@@ -639,15 +647,32 @@
***********************************************************************/
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 = (const char **)datafilelist(TILESPEC_SUFFIX);
+ 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);
+ } else {
+ free(list[i]);
+ }
+ }
+
+ tilesets = fc_realloc(tilesets, (count + 1) * sizeof(*tilesets));
+ tilesets[count] = NULL;
}
- return tileset_list;
+ return tilesets;
}
/**********************************************************************
@@ -672,12 +697,6 @@
tileset_name = tileset_default;
}
- /* Hack: this is the name of the tileset we're about to load. We copy
- * it here, since this is the only place where we know it. Note this
- * also means if you do "civ -t foo" this will change your *default*
- * tileset to 'foo'. */
- sz_strlcpy(default_tileset_name, tileset_name);
-
fname = fc_malloc(strlen(tileset_name) + strlen(TILESPEC_SUFFIX) + 1);
sprintf(fname, "%s%s", tileset_name, TILESPEC_SUFFIX);
@@ -709,7 +728,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"),
@@ -717,7 +736,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"
@@ -808,6 +827,8 @@
die("Failed to re-read the currently loaded tileset.");
}
}
+ sz_strlcpy(default_tileset_name, tileset->name);
+
tileset_load_tiles(tileset);
/* Step 3: Setup
Index: client/tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.147
diff -u -r1.147 tilespec.h
--- client/tilespec.h 11 Apr 2005 22:11:41 -0000 1.147
+++ client/tilespec.h 13 Apr 2005 06:31:50 -0000
@@ -208,6 +208,7 @@
const struct unit *punit);
/* Tileset accessor functions. */
+const char *tileset_get_name(const struct tileset *t);
bool tileset_is_isometric(const struct tileset *t);
int tileset_hex_width(const struct tileset *t);
int tileset_hex_height(const struct tileset *t);
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 13 Apr 2005 06:31:50 -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 13 Apr 2005 06:31:50 -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 13 Apr 2005 06:31:50 -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 13 Apr 2005 06:31:50 -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"
|
|