diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index b42fd8ef..cac83323 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -148,6 +148,28 @@ void Graphics::init() kludgeswnlinewidth = false; } +void Graphics::destroy() +{ + #define CLEAR_ARRAY(name) \ + for (size_t i = 0; i < name.size(); i += 1) \ + { \ + SDL_FreeSurface(name[i]); \ + } \ + name.clear(); + + CLEAR_ARRAY(tiles) + CLEAR_ARRAY(tiles2) + CLEAR_ARRAY(tiles3) + CLEAR_ARRAY(entcolours) + CLEAR_ARRAY(sprites) + CLEAR_ARRAY(flipsprites) + CLEAR_ARRAY(tele) + CLEAR_ARRAY(bfont) + CLEAR_ARRAY(flipbfont) + + #undef CLEAR_ARRAY +} + int Graphics::font_idx(uint32_t ch) { if (font_positions.size() > 0) { std::map::iterator iter = font_positions.find(ch); @@ -3150,24 +3172,7 @@ void Graphics::reloadresources() grphx.destroy(); grphx.init(); - #define CLEAR_ARRAY(name) \ - for (size_t i = 0; i < name.size(); i += 1) \ - { \ - SDL_FreeSurface(name[i]); \ - } \ - name.clear(); - - CLEAR_ARRAY(tiles) - CLEAR_ARRAY(tiles2) - CLEAR_ARRAY(tiles3) - CLEAR_ARRAY(entcolours) - CLEAR_ARRAY(sprites) - CLEAR_ARRAY(flipsprites) - CLEAR_ARRAY(tele) - CLEAR_ARRAY(bfont) - CLEAR_ARRAY(flipbfont) - - #undef CLEAR_ARRAY + destroy(); MakeTileArray(); MakeSpriteArray(); diff --git a/desktop_version/src/Graphics.h b/desktop_version/src/Graphics.h index f23088e3..d6467f2c 100644 --- a/desktop_version/src/Graphics.h +++ b/desktop_version/src/Graphics.h @@ -17,6 +17,7 @@ class Graphics { public: void init(); + void destroy(); GraphicsResources grphx;