Author: cazfi Date: Mon Jan 25 12:24:17 2016 New Revision: 31583 URL: http://svn.gna.org/viewcvs/freeciv?rev=31583&view=rev Log: tileset_load_toplevel() can be limited to accept only specific topology tileset.
See patch #6844 Modified: branches/S2_6/client/tilespec.c branches/S2_6/client/tilespec.h Modified: branches/S2_6/client/tilespec.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/tilespec.c?rev=31583&r1=31582&r2=31583&view=diff ============================================================================== --- branches/S2_6/client/tilespec.c (original) +++ branches/S2_6/client/tilespec.c Mon Jan 25 12:24:17 2016 @@ -983,7 +983,7 @@ tilesets = strvec_new(); strvec_iterate(list, file) { - struct tileset *t = tileset_read_toplevel(file, FALSE); + struct tileset *t = tileset_read_toplevel(file, FALSE, -1); if (t) { strvec_append(tilesets, file); @@ -1159,11 +1159,11 @@ ***********************************************************************/ void tilespec_try_read(const char *tileset_name, bool verbose) { - if (!(tileset = tileset_read_toplevel(tileset_name, verbose))) { + if (!(tileset = tileset_read_toplevel(tileset_name, verbose, -1))) { struct strvec *list = fileinfolist(get_data_dirs(), TILESPEC_SUFFIX); strvec_iterate(list, file) { - struct tileset *t = tileset_read_toplevel(file, FALSE); + struct tileset *t = tileset_read_toplevel(file, FALSE, -1); if (t) { if (!tileset) { @@ -1233,8 +1233,8 @@ * * We read in the new tileset. This should be pretty straightforward. */ - if (!(tileset = tileset_read_toplevel(tileset_name, FALSE))) { - if (!(tileset = tileset_read_toplevel(old_name, FALSE))) { + if (!(tileset = tileset_read_toplevel(tileset_name, FALSE, -1))) { + if (!(tileset = tileset_read_toplevel(old_name, FALSE, -1))) { /* Always fails. */ fc_assert_exit_msg(NULL != tileset, "Failed to re-read the currently loaded tileset."); @@ -1613,8 +1613,10 @@ Finds and reads the toplevel tilespec file based on given name. Sets global variables, including tile sizes and full names for intro files. + topology_id of -1 means any topology is acceptable. ***********************************************************************/ -struct tileset *tileset_read_toplevel(const char *tileset_name, bool verbose) +struct tileset *tileset_read_toplevel(const char *tileset_name, bool verbose, + int topology_id) { struct section_file *file; char *fname; @@ -1630,6 +1632,7 @@ struct tileset *t = NULL; const char *extraname; const char *tstr; + int topo; fname = tilespec_fullname(tileset_name); if (!fname) { @@ -1721,6 +1724,12 @@ goto ON_ERROR; } + if (t->type == TS_ISOMETRIC) { + topo = TF_ISO; + } else { + topo = 0; + } + /* Read hex-tileset information. */ t->hex_width = t->hex_height = 0; if (is_hex) { @@ -1736,10 +1745,18 @@ } else { t->hex_height = hex_side; } + + topo |= TF_HEX; + /* Hex tilesets are drawn the same as isometric. */ /* FIXME: There will be other legal values to be used with hex * tileset in the future, and this would just overwrite it. */ t->type = TS_ISOMETRIC; + } + + if (topology_id >= 0 && topo != (topology_id & (TF_ISO | TF_HEX))) { + /* Not of requested topology */ + goto ON_ERROR; } if (!is_view_supported(t->type)) { Modified: branches/S2_6/client/tilespec.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/tilespec.h?rev=31583&r1=31582&r2=31583&view=diff ============================================================================== --- branches/S2_6/client/tilespec.h (original) +++ branches/S2_6/client/tilespec.h Mon Jan 25 12:24:17 2016 @@ -174,7 +174,8 @@ void tileset_error(enum log_level level, const char *format, ...); -struct tileset *tileset_read_toplevel(const char *tileset_name, bool verbose); +struct tileset *tileset_read_toplevel(const char *tileset_name, bool verbose, + int topology_id); void tileset_init(struct tileset *t); void tileset_free(struct tileset *tileset); void tileset_load_tiles(struct tileset *t); _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits