.Forty-Five is a deckbuilding card game set in the wild west. Collect and master powerful cards, battle different enemies and try not to end up six feet deep!
When interacting with the Backpack (e.g. swapping cards in the deck) a lot, the framerate goes down dramatically. This happens because these changes cause functions like Backpack::reloadDeck to be called, which in turn calls Backpack::getCard for every card in the deck, generating a new texture each time. Also the old textures are not disposed, causing a significant memory leak.
Sorting cards or moving cards from the deck to the backpack / from the backpack to the deck causes simmilar behaviour.
Steps to Reproduce
Open backpack
Open task Manager to monitor RAM usage
Show FrameRate (in the newest version by pressing 'T', or using the logger)
Swap cards in the deck until the behaviour is observed. This happens more quickly if there a lot of cards in the backpack/deck.
Possible fix
The backpack should create each card only once and reuse them. When a screen transition occurs, the backpack should dispose the created cards. Sorting/swapping cards should only rearrange them and not regenerate them.
the source of the problem is different, "card in the deck, generating a new texture each time" is wrong, since it only access the cards which were previously generated at the end of the "init" method
Description
When interacting with the Backpack (e.g. swapping cards in the deck) a lot, the framerate goes down dramatically. This happens because these changes cause functions like
Backpack::reloadDeck
to be called, which in turn callsBackpack::getCard
for every card in the deck, generating a new texture each time. Also the old textures are not disposed, causing a significant memory leak. Sorting cards or moving cards from the deck to the backpack / from the backpack to the deck causes simmilar behaviour.Steps to Reproduce
Possible fix
The backpack should create each card only once and reuse them. When a screen transition occurs, the backpack should dispose the created cards. Sorting/swapping cards should only rearrange them and not regenerate them.
Version
tested in dev and b240207