Skip to content

Commit

Permalink
Finished Norman's clean up method
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirA97 committed Apr 26, 2017
1 parent 3cdbabb commit e8704d3
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 39 deletions.
2 changes: 1 addition & 1 deletion GunBird - Coded Dreams/Enemy_The_Trump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Enemy_The_Trump::~Enemy_The_Trump()
if (texture_bg_upper2 != nullptr)
{
App->textures->Unload(texture_bg_upper2);
texture_bg_upper = nullptr;
texture_bg_upper2 = nullptr;
}
}

Expand Down
2 changes: 1 addition & 1 deletion GunBird - Coded Dreams/Enemy_Torpedo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Enemy_Torpedo::~Enemy_Torpedo()
if (NormalSprite != nullptr)
{
App->textures->Unload(NormalSprite);
RedSprite = nullptr;
NormalSprite = nullptr;
}
if (RedSprite != nullptr)
{
Expand Down
16 changes: 2 additions & 14 deletions GunBird - Coded Dreams/ModuleParticles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,74 +223,62 @@ bool ModuleParticles::CleanUp()
App->textures->Unload(MARION_bullet_p1_texture);
MARION_bullet_p1_texture = nullptr;
}
if (MARION_bullet_p1_texture != nullptr)
if (MARION_bullet_p2_texture != nullptr)
{
App->textures->Unload(MARION_bullet_p2_texture);
MARION_bullet_p2_texture = nullptr;
}

if (ASH_bullet_p1_texture != nullptr)
{
App->textures->Unload(ASH_bullet_p1_texture);
ASH_bullet_p1_texture = nullptr;
}

if (ASH_bullet_p2_texture != nullptr)
{
App->textures->Unload(ASH_bullet_p2_texture);
ASH_bullet_p2_texture = nullptr;
}

if (upgrade_texture != nullptr)
{
App->textures->Unload(upgrade_texture);
upgrade_texture = nullptr;
}

if (small_shot_texture != nullptr)
{
App->textures->Unload(small_shot_texture);
upgrade_texture = nullptr;
small_shot_texture = nullptr;
}

if (explosions_texture != nullptr)
{
App->textures->Unload(explosions_texture);
explosions_texture = nullptr;
}

if (big_shot_texture != nullptr)
{
App->textures->Unload(big_shot_texture);
big_shot_texture = nullptr;
}

if (explosion_building1_texture != nullptr)
{
App->textures->Unload(explosion_building1_texture);
explosion_building1_texture = nullptr;
}

if (explosion_torpedo_texture != nullptr)
{
App->textures->Unload(explosion_torpedo_texture);
explosion_torpedo_texture = nullptr;
}

if (explosion_antiaircraft_texture != nullptr)
{
App->textures->Unload(explosion_antiaircraft_texture);
explosion_antiaircraft_texture = nullptr;
}

if (explosion_pot_texture != nullptr)
{
App->textures->Unload(explosion_pot_texture);
explosion_pot_texture = nullptr;
}



for (uint i = 0; i < MAX_ACTIVE_PARTICLES; ++i)
{
if (active[i] != nullptr)
Expand Down
43 changes: 30 additions & 13 deletions GunBird - Coded Dreams/ModuleSceneCastle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,19 +179,36 @@ bool ModuleSceneCastle::Start()
bool ModuleSceneCastle::CleanUp()
{
LOG("Unloading Castle scene");
App->textures->Unload(texture_bg);
App->textures->Unload(texture_bg_upper);
App->textures->Unload(texture_1_river);
App->textures->Unload(texture_2_river);
App->textures->Unload(texture_bridge);
App->textures->Unload(texture_the_trump);

texture_bg = nullptr;
texture_bg_upper = nullptr;
texture_1_river = nullptr;
texture_2_river = nullptr;
texture_bridge = nullptr;
texture_the_trump = nullptr;
if (texture_bg != nullptr)
{
App->textures->Unload(texture_bg);
texture_bg = nullptr;
}
if (texture_bg_upper != nullptr)
{
App->textures->Unload(texture_bg_upper);
texture_bg_upper = nullptr;
}
if (texture_1_river != nullptr)
{
App->textures->Unload(texture_1_river);
texture_1_river = nullptr;
}
if (texture_2_river != nullptr)
{
App->textures->Unload(texture_2_river);
texture_2_river = nullptr;
}
if (texture_bridge != nullptr)
{
App->textures->Unload(texture_bridge);
texture_bridge = nullptr;
}
if (texture_the_trump != nullptr)
{
App->textures->Unload(texture_the_trump);
texture_the_trump = nullptr;
}

App->audio->Stop();
App->marion->Disable();
Expand Down
15 changes: 10 additions & 5 deletions GunBird - Coded Dreams/ModuleSceneMine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,16 @@ bool ModuleSceneMine::Start()
bool ModuleSceneMine::CleanUp()
{
LOG("Unloading Mine scene");
App->textures->Unload(graphics_above_background_text);
App->textures->Unload(graphics_background_text);

graphics_above_background_text = nullptr;
graphics_background_text = nullptr;
if (graphics_above_background_text != nullptr)
{
App->textures->Unload(graphics_above_background_text);
graphics_above_background_text = nullptr;
}
if (graphics_background_text != nullptr)
{
App->textures->Unload(graphics_background_text);
graphics_background_text = nullptr;
}

App->audio->Stop();
App->marion->Disable();
Expand Down
8 changes: 6 additions & 2 deletions GunBird - Coded Dreams/ModuleSelection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ bool ModuleSelection::Start()
bool ModuleSelection::CleanUp()
{
LOG("Unloading Selection scene");
App->textures->Unload(graphics);
graphics = nullptr;
if (graphics != nullptr)
{
App->textures->Unload(graphics);
graphics = nullptr;
}

App->audio->Stop();

return true;
Expand Down
7 changes: 6 additions & 1 deletion GunBird - Coded Dreams/ModuleUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,24 @@ bool ModuleUI::CleanUp()
if (marion_texture != nullptr)
{
App->textures->Unload(marion_texture);
marion_texture = nullptr;
}
if (ash_texture != nullptr)
{
App->textures->Unload(ash_texture);
ash_texture = nullptr;
}
if (marion_texture != nullptr)
if (game_over != nullptr)
{
App->textures->Unload(game_over);
game_over = nullptr;
}
if (char_lives != nullptr)
{
App->textures->Unload(char_lives);
char_lives = nullptr;
}

App->fonts->Unload(font_score);
App->fonts->Unload(highscores_score);
App->fonts->Disable();
Expand Down
8 changes: 6 additions & 2 deletions GunBird - Coded Dreams/ModuleWelcomeTitle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@ bool ModuleWelcomeTitle::Start()
bool ModuleWelcomeTitle::CleanUp()
{
LOG("Unloading WelcomeTitle scene");
App->textures->Unload(graphics);
graphics = nullptr;
if (graphics != nullptr)
{
App->textures->Unload(graphics);
graphics = nullptr;
}

App->audio->Stop();

return true;
Expand Down

0 comments on commit e8704d3

Please sign in to comment.