Skip to content

Commit

Permalink
Issue 952: Unloading/freeing all tilesets prior to shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
tobbi committed Sep 27, 2013
1 parent 194b778 commit fc62bc7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/supertux/resources.cpp
Expand Up @@ -36,6 +36,10 @@ 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 @@ -59,6 +63,11 @@ 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 @@ -77,6 +86,14 @@ Resources::unload_shared()
normal_font.reset();
small_font.reset();
big_font.reset();

/* Free tilesets */
delete worldmap_tiles;
worldmap_tiles = NULL;
delete general_tiles;
general_tiles = NULL;
delete iceworld_tiles;
iceworld_tiles = NULL;

delete sprite_manager;
sprite_manager = NULL;
Expand Down
6 changes: 6 additions & 0 deletions src/supertux/resources.hpp
Expand Up @@ -20,6 +20,7 @@

#include "video/font_ptr.hpp"
#include "video/surface_ptr.hpp"
#include "supertux/tile_set.hpp"

class MouseCursor;

Expand All @@ -39,6 +40,11 @@ class Resources
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();
static void unload_shared();
Expand Down

0 comments on commit fc62bc7

Please sign in to comment.