Skip to content

Commit

Permalink
More effective method of freeing tilesets
Browse files Browse the repository at this point in the history
  • Loading branch information
tobbi committed Sep 28, 2013
1 parent fc62bc7 commit 5f76d41
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
21 changes: 6 additions & 15 deletions src/supertux/resources.cpp
Expand Up @@ -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()
Expand All @@ -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: */
Expand All @@ -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;
Expand Down
5 changes: 0 additions & 5 deletions src/supertux/resources.hpp
Expand Up @@ -39,11 +39,6 @@ class Resources
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();
Expand Down
1 change: 1 addition & 0 deletions src/supertux/tile_manager.hpp
Expand Up @@ -26,6 +26,7 @@ class TileSet;

class TileManager
{
friend class Resources;
private:
typedef std::map<std::string, TileSet*> TileSets;
TileSets tilesets;
Expand Down

0 comments on commit 5f76d41

Please sign in to comment.