- tiles_path = FileSystem::dirname(filename);
-
- tiles.resize(1, 0);
- tiles[0] = new Tile(this);
-
- lisp::Parser parser;
- const lisp::Lisp* root = parser.parse(filename);
-
- const lisp::Lisp* tiles_lisp = root->get_lisp("supertux-tiles");
- if(!tiles_lisp)
- throw std::runtime_error("file is not a supertux tiles file.");
-
- lisp::ListIterator iter(tiles_lisp);
- while(iter.next()) {
- if(iter.item() == "tile") {
- std::auto_ptr<Tile> tile(new Tile(this));
- uint32_t id = tile->parse(*(iter.lisp()));
-
- if(id >= tiles.size())
- tiles.resize(id+1, 0);
-
- if(tiles[id] != 0) {
- log_warning << "Tile with ID " << id << " redefined" << std::endl;
- } else {
- tiles[id] = tile.release();
- }
- } else if(iter.item() == "tilegroup") {
- /* tilegroups are only interesting for the editor */
- } else if (iter.item() == "tiles") {
- // List of ids (use 0 if the tile should be ignored)
- std::vector<uint32_t> ids;
- // List of attributes of the tile
- std::vector<uint32_t> attributes;
- // List of data for the tiles
- std::vector<uint32_t> datas;
- //List of frames that the tiles come in
- std::vector<std::string> images;
-
- // width and height of the image in tile units, this is used for two
- // purposes:
- // a) so we don't have to load the image here to know its dimensions
- // b) so that the resulting 'tiles' entry is more robust,
- // ie. enlarging the image won't break the tile id mapping
- // FIXME: height is actually not used, since width might be enough for
- // all purposes, still feels somewhat more natural this way
- unsigned int width = 0;
- unsigned int height = 0;
-
- iter.lisp()->get("ids", ids);
- bool has_attributes = iter.lisp()->get("attributes", attributes);
- bool has_datas = iter.lisp()->get("datas", datas);
-
- if(!iter.lisp()->get("image", images))
- iter.lisp()->get( "images", images);
-
- iter.lisp()->get("width", width);
- iter.lisp()->get("height", height);
-
- float animfps = 10;
- iter.lisp()->get("anim-fps", animfps);