From dae824ab759e13de821017af50b47332ff7b6a4f Mon Sep 17 00:00:00 2001 From: Muzychenko Andrey <33288308+k4zmu2a@users.noreply.github.com> Date: Mon, 30 May 2022 09:02:54 +0300 Subject: [PATCH] Added cleanup for ball_bitmap memory. --- SpaceCadetPinball/TLightGroup.cpp | 2 +- SpaceCadetPinball/render.cpp | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/SpaceCadetPinball/TLightGroup.cpp b/SpaceCadetPinball/TLightGroup.cpp index 1ecdaf2..5828ac5 100644 --- a/SpaceCadetPinball/TLightGroup.cpp +++ b/SpaceCadetPinball/TLightGroup.cpp @@ -14,7 +14,7 @@ TLightGroup::TLightGroup(TPinballTable* table, int groupIndex) : TPinballCompone List = new objlist_class(4, 4); Timer = 0; NotifyTimer = 0; - Reset(); + TLightGroup::Reset(); if (groupIndex > 0) { int count; diff --git a/SpaceCadetPinball/render.cpp b/SpaceCadetPinball/render.cpp index 19e120e..10355b8 100644 --- a/SpaceCadetPinball/render.cpp +++ b/SpaceCadetPinball/render.cpp @@ -29,12 +29,8 @@ void render::init(gdrv_bitmap8* bmp, float zMin, float zScaler, int width, int h vscreen_rect.Height = height; vscreen.YPosition = 0; vscreen.XPosition = 0; - gdrv_bitmap8* ballBmp = ball_bitmap; - while (ballBmp < &ball_bitmap[20]) - { - gdrv::create_raw_bitmap(ballBmp, 64, 64, 1); - ++ballBmp; - } + for (auto& ballBmp : ball_bitmap) + gdrv::create_raw_bitmap(&ballBmp, 64, 64, 1); background_bitmap = bmp; if (bmp) gdrv::copy_bitmap(&vscreen, width, height, 0, 0, bmp, 0, 0); @@ -51,6 +47,8 @@ void render::uninit() remove_sprite(sprite_list[i]); for (auto j = many_balls - 1; j >= 0; --j) remove_ball(ball_list[j]); + for (auto& ballBmp : ball_bitmap) + gdrv::destroy_bitmap(&ballBmp); memory::free(ball_list); memory::free(dirty_list); memory::free(sprite_list);