MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / tilesetAssetPath

Function tilesetAssetPath

source/game/StarDungeonTMXPart.cpp:227–242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

225 }
226
227 String tilesetAssetPath(String const& relativePath) {
228 // Tiled stores tileset paths relative to the map file, which can go below
229 // the assets root if it's referencing a tileset in another asset package.
230 // The solution chosen here is to ignore everything in the path up until a
231 // known path segment, e.g.:
232 // "source" : "..\/..\/..\/..\/packed\/tilesets\/packed\/materials.json"
233 // We ignore everything up until the 'tilesets' path segment, and the asset
234 // we actually load is located at:
235 // /tilesets/packed/materials.json
236
237 size_t i = relativePath.findLast("/tilesets/", String::CaseInsensitive);
238 if (i == NPos)
239 // Couldn't extract the right path, try the one we were given in the Json.
240 return relativePath;
241 return relativePath.slice(i);
242 }
243
244 TMXTilesets::TMXTilesets(Json const& tmx) {
245 for (Json const& tilesetJson : tmx.iterateArray()) {

Callers 1

TMXTilesetsMethod · 0.85

Calls 2

findLastMethod · 0.45
sliceMethod · 0.45

Tested by

no test coverage detected