• Simon Goller's avatar
    Fix future memory leak of registered images · fccc526d
    Simon Goller authored and neosam's avatar neosam committed
    Sprites were loaded during the level_loading und the level images in
    InGameState::new() but they were never cleaned up.  As soon as the
    InGameState starts several times, this would lead to a memory leak.
    This commit contains a separate treatment for sprites and the level
    Since sprites are stored as a global Enum, they will now be initialized
    only once on the first loading state.  When loading the images, they
    check if the ImageHandle is already registered on the renderer to
    determine if loading is required.
    Level foreground and background on the other hand are dynamically loaded
    in the InGameState.  The InGameState got a new attribute
    `registered_images: Vec<resources::ImageHandle>` which stores all
    `ImageHandle` of dynamically loaded images.  On deinint, they
    get deregistered from `Rendering`.
ingame.rs 4.75 KB