Skip to content

Commit

Permalink
Fixed problem with embedding or exporting tilesets with Wang sets
Browse files Browse the repository at this point in the history
The Wang sets were not cloned completely, missing their edge and corner
colors. This would result in an invalid Wang set that would fail to load.

See http://discourse.mapeditor.org/t/tiled-fails-to-open-maps-with-embedded-tilesets/3040
  • Loading branch information
bjorn committed Mar 13, 2018
1 parent 6a5ca7d commit 4ae4ff6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/libtiled/wangset.cpp
Expand Up @@ -783,10 +783,16 @@ WangId WangSet::templateWangIdAt(unsigned n) const

WangSet *WangSet::clone(Tileset *tileset) const
{
WangSet *c = new WangSet(tileset, mName, mImageTileId);
WangSet *c = new WangSet(*this);

c->mWangIdToWangTile = mWangIdToWangTile;
c->mTileInfoToWangId = mTileInfoToWangId;
// Caller is responsible for adding the WangSet to this tileset
c->setTileset(tileset);

// Avoid sharing wang colors
for (QSharedPointer<WangColor> &wangColor : c->mEdgeColors)
wangColor.reset(new WangColor(*wangColor));
for (QSharedPointer<WangColor> &wangColor : c->mCornerColors)
wangColor.reset(new WangColor(*wangColor));

return c;
}

0 comments on commit 4ae4ff6

Please sign in to comment.