From: Tobias Markus Date: Sat, 28 Sep 2013 21:13:49 +0000 (+0200) Subject: More effective method of freeing tilesets X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=5f76d41d14adc349b1ad5820aaba9d1c2831aa34;p=supertux.git More effective method of freeing tilesets --- diff --git a/src/supertux/resources.cpp b/src/supertux/resources.cpp index 589dcc6e2..17ef56b3c 100644 --- a/src/supertux/resources.cpp +++ b/src/supertux/resources.cpp @@ -36,10 +36,6 @@ SurfacePtr Resources::back; SurfacePtr Resources::arrow_left; SurfacePtr Resources::arrow_right; -TileSet* Resources::general_tiles; -TileSet* Resources::worldmap_tiles; -TileSet* Resources::iceworld_tiles; - /* Load graphics/sounds shared between all levels: */ void Resources::load_shared() @@ -63,11 +59,6 @@ Resources::load_shared() tile_manager = new TileManager(); sprite_manager = new SpriteManager(); - - /* Create a reference to tilesets */ - general_tiles = tile_manager->get_tileset("images/tiles.strf"); - worldmap_tiles = tile_manager->get_tileset("images/worldmap.strf"); - iceworld_tiles = tile_manager->get_tileset("images/ice_world.strf"); } /* Free shared data: */ @@ -88,12 +79,12 @@ Resources::unload_shared() big_font.reset(); /* Free tilesets */ - delete worldmap_tiles; - worldmap_tiles = NULL; - delete general_tiles; - general_tiles = NULL; - delete iceworld_tiles; - iceworld_tiles = NULL; + for(TileManager::TileSets::iterator it = tile_manager->tilesets.begin(); + it != tile_manager->tilesets.end(); ++it) + { + delete it->second; + it->second = NULL; + } delete sprite_manager; sprite_manager = NULL; diff --git a/src/supertux/resources.hpp b/src/supertux/resources.hpp index 8dc5b119a..746601028 100644 --- a/src/supertux/resources.hpp +++ b/src/supertux/resources.hpp @@ -39,11 +39,6 @@ public: static SurfacePtr back; static SurfacePtr arrow_left; static SurfacePtr arrow_right; - -private: - static TileSet* general_tiles; - static TileSet* worldmap_tiles; - static TileSet* iceworld_tiles; public: static void load_shared(); diff --git a/src/supertux/tile_manager.hpp b/src/supertux/tile_manager.hpp index 8d081ee36..5d1317ea2 100644 --- a/src/supertux/tile_manager.hpp +++ b/src/supertux/tile_manager.hpp @@ -26,6 +26,7 @@ class TileSet; class TileManager { + friend class Resources; private: typedef std::map TileSets; TileSets tilesets;