Fix core dump & clearer music deallocation
This commit is contained in:
parent
c15e4e48a5
commit
f657c49c79
17
src/maps.cpp
17
src/maps.cpp
|
@ -1,11 +1,8 @@
|
|||
#include "maps.h"
|
||||
|
||||
Maps::Maps(SDL_Renderer* render){
|
||||
int sound = false;
|
||||
if(false) Mix_OpenAudio( 44100, MIX_DEFAULT_FORMAT, 2, 2048 );
|
||||
|
||||
if(sound == true){
|
||||
Mix_OpenAudio( 44100, MIX_DEFAULT_FORMAT, 2, 2048 );
|
||||
}
|
||||
//Set renderer
|
||||
renderer = render;
|
||||
|
||||
|
@ -31,8 +28,9 @@ Maps::~Maps(){
|
|||
//Deallocate rows
|
||||
for(int i = 0; i < blockTotal; ++i) delete blockRect[i];
|
||||
//Deallocate
|
||||
delete blockRect;
|
||||
//delete blockRect;
|
||||
|
||||
Mix_HaltMusic();
|
||||
|
||||
//Free the music
|
||||
Mix_FreeMusic( gMusic );
|
||||
|
@ -107,7 +105,6 @@ int Maps::map(std::string mapName){
|
|||
}
|
||||
}
|
||||
if(currentKeyStates[SDL_SCANCODE_ESCAPE]){
|
||||
musicQuit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -141,13 +138,5 @@ int Maps::map(std::string mapName){
|
|||
//Render
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
musicQuit();
|
||||
return -1;
|
||||
}
|
||||
|
||||
void Maps::musicQuit(){
|
||||
Mix_HaltMusic();
|
||||
//Free the music
|
||||
Mix_FreeMusic( gMusic );
|
||||
gMusic = NULL;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ class Maps{
|
|||
int map(std::string mapName);
|
||||
private:
|
||||
void loadMap(std::string path);
|
||||
void musicQuit();
|
||||
|
||||
SDL_Renderer* renderer;
|
||||
|
||||
|
|
Loading…
Reference in New Issue