Skip to content

Commit fb01856

Browse files
committed
Add a proper check for whether a tileset is imported
1 parent 431c099 commit fb01856

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/supertux/tile_set_parser.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ TileSetParser::TileSetParser(TileSet& tileset, const std::string& filename) :
3939
}
4040

4141
void
42-
TileSetParser::parse(uint32_t start, uint32_t end, int32_t offset)
42+
TileSetParser::parse(uint32_t start, uint32_t end, int32_t offset, bool imported)
4343
{
4444
if (offset && static_cast<int32_t>(start) + offset < 1) {
4545
start = -offset + 1;
@@ -70,8 +70,8 @@ TileSetParser::parse(uint32_t start, uint32_t end, int32_t offset)
7070
else if (iter.get_key() == "tilegroup")
7171
{
7272
/* tilegroups are only interesting for the editor */
73-
/* ignore tilegroups for imported tilesets unless there's no limit and no offset*/
74-
if (start || end || offset) continue;
73+
/* ignore tilegroups for imported tilesets */
74+
if (imported) continue;
7575
ReaderMapping reader = iter.as_mapping();
7676
Tilegroup tilegroup;
7777
reader.get("name", tilegroup.name);
@@ -85,8 +85,8 @@ TileSetParser::parse(uint32_t start, uint32_t end, int32_t offset)
8585
}
8686
else if (iter.get_key() == "autotileset")
8787
{
88-
/* ignore autotiles for imported tilesets unless there's no limit and no offset */
89-
if (start || end || offset) continue;
88+
/* ignore autotiles for imported tilesets */
89+
if (imported) continue;
9090
ReaderMapping reader = iter.as_mapping();
9191
std::string autotile_filename;
9292
if (!reader.get("source", autotile_filename))
@@ -111,15 +111,15 @@ TileSetParser::parse(uint32_t start, uint32_t end, int32_t offset)
111111
reader.get("end", import_end);
112112
reader.get("offset", import_offset);
113113
TileSetParser import_parser(m_tileset, import_filename);
114-
import_parser.parse(import_start, import_end, import_offset);
114+
import_parser.parse(import_start, import_end, import_offset, true);
115115
}
116116
else
117117
{
118118
log_warning << "Unknown symbol '" << iter.get_key() << "' in tileset file" << std::endl;
119119
}
120120
}
121121
/* only create the unassigned tilegroup from the parent strf */
122-
if (g_config->developer_mode && !end)
122+
if (g_config->developer_mode && !imported)
123123
{
124124
m_tileset.add_unassigned_tilegroup();
125125
}

src/supertux/tile_set_parser.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class TileSetParser final
3838
public:
3939
TileSetParser(TileSet& tileset, const std::string& filename);
4040

41-
void parse(uint32_t start = 0, uint32_t end = 0, int32_t offset = 0);
41+
void parse(uint32_t start = 0, uint32_t end = 0, int32_t offset = 0, bool imported = false);
4242

4343
private:
4444
void parse_tile(const ReaderMapping& reader, uint32_t min, uint32_t max, int32_t offset);

0 commit comments

Comments
 (0)