[Freeciv-Dev] Re: (PR#6893) trident_shields broken
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] Re: (PR#6893) trident_shields broken |
From: |
"Arnstein Lindgard" <a-l@xxxxxxx> |
Date: |
Thu, 20 Nov 2003 07:17:11 -0800 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=6893 >
I wrote:
> civclient -t trident_shields is completely broken.
I'm not very into the sprite loading code yet, but I think this patch
is the proper way to support the "duplicates_ok" flag. It seems like
someone intended to implement it, but forgot. The patch makes
trident_shields work, but when a toplevel .tilespec files lacks the
"duplicates_ok" flag you will still get warnings about duplicate
tags, and the last read tag will _not_ be applied.
Changelog:
Thu Jan 13 11:59:33 2000 David Pfitzner <dwp@xxxxxxxxxxxxxx>:
* README.graphics, client/tilespec.c, common/registry.c,
common/registry.h, data/engels.tilespec, data/trident.tilespec:
Extend "tilespec" system to allow duplicate tags, to allow
convenient overriding of individual graphics without having to
change base spec files. For duplicated tags, the last appearing
tag applies ("last" in terms of order of specified files in
toplevel tilespec file, and within each file). Toplevel tilespec
files can add tag "+duplicates_ok" to options list to require this
capability.
Arnstein
--- freeciv/client/tilespec.c Wed Oct 15 23:15:46 2003
+++ shields/client/tilespec.c Tue Nov 18 19:40:26 2003
@@ -446,7 +446,7 @@
positions of the sprites in the big_sprite are saved in the
small_sprite structs.
**************************************************************************/
-static void scan_specfile(struct specfile *sf)
+static void scan_specfile(struct specfile *sf, bool duplicates_ok)
{
struct section_file the_file, *file = &the_file;
char **gridnames;
@@ -517,12 +517,18 @@
small_sprite_list_insert(&ss->sf->small_sprites, ss);
- for (k = 0; k < num_tags; k++) {
- if (!hash_insert(sprite_hash, mystrdup(tags[k]), ss)) {
- freelog(LOG_ERROR, "warning: already have a sprite for %s",
- tags[k]);
- }
+ if (!duplicates_ok) {
+ for (k = 0; k < num_tags; k++) {
+ if (!hash_insert(sprite_hash, mystrdup(tags[k]), ss)) {
+ freelog(LOG_ERROR, "warning: already have a sprite for %s",
tags[k]);
+ }
+ }
+ } else {
+ for (k = 0; k < num_tags; k++) {
+ (void) hash_replace(sprite_hash, mystrdup(tags[k]), ss);
+ }
}
+
free(tags);
tags = NULL;
}
@@ -575,6 +581,8 @@
int i;
int num_spec_files;
char **spec_filenames;
+ char *file_capstr;
+ bool duplicates_ok;
fname = tilespec_fullname(tileset_name);
freelog(LOG_VERBOSE, "tilespec file is %s", fname);
@@ -585,6 +593,9 @@
}
check_tilespec_capabilities(file, "tilespec", TILESPEC_CAPSTR, fname);
+ file_capstr = secfile_lookup_str(file, "%s.options", "tilespec");
+ duplicates_ok = has_capabilities("+duplicates_ok", file_capstr);
+
(void) section_file_lookup(file, "tilespec.name"); /* currently unused */
is_isometric = secfile_lookup_bool_default(file, FALSE,
"tilespec.is_isometric");
@@ -665,7 +676,7 @@
sf->big_sprite = NULL;
sf->file_name = mystrdup(datafilename_required(spec_filenames[i]));
small_sprite_list_init(&sf->small_sprites);
- scan_specfile(sf);
+ scan_specfile(sf, duplicates_ok);
specfile_list_insert(&specfiles, sf);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] Re: (PR#6893) trident_shields broken,
Arnstein Lindgard <=
|
|