Merge pull request #23 from CrystalPointA4/feature/soundsystemfix
Sound pointers worden gedelete
This commit is contained in:
@@ -32,7 +32,7 @@ Enemy::~Enemy()
|
|||||||
if (model)
|
if (model)
|
||||||
Model::unload(model);
|
Model::unload(model);
|
||||||
|
|
||||||
delete music;
|
CrystalPoint::GetSoundSystem().UnloadSound(hit_sound_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Enemy::draw()
|
void Enemy::draw()
|
||||||
|
|||||||
+1
-2
@@ -30,7 +30,7 @@ Portal::Portal(const std::string &fileName,
|
|||||||
Portal::~Portal()
|
Portal::~Portal()
|
||||||
{
|
{
|
||||||
// Model::unload(model);
|
// Model::unload(model);
|
||||||
// delete music;
|
CrystalPoint::GetSoundSystem().UnloadSound(sound_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Portal::collide()
|
void Portal::collide()
|
||||||
@@ -46,7 +46,6 @@ bool Portal::enter(float deltaTime)
|
|||||||
{
|
{
|
||||||
if (delay > 3 && started)
|
if (delay > 3 && started)
|
||||||
{
|
{
|
||||||
delete music;
|
|
||||||
delay = 0;
|
delay = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,3 +48,11 @@ Sound* SoundSystem::GetSound(unsigned int inID)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
return sounds[inID];
|
return sounds[inID];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SoundSystem::UnloadSound(unsigned int inID)
|
||||||
|
{
|
||||||
|
if (inID > sounds.size())
|
||||||
|
return;
|
||||||
|
delete sounds[inID];
|
||||||
|
//sounds.erase(sounds.begin() + inID);
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ public:
|
|||||||
|
|
||||||
unsigned int LoadSound(const char* inWavPath, bool inLooping);
|
unsigned int LoadSound(const char* inWavPath, bool inLooping);
|
||||||
Sound* GetSound(unsigned int inID);
|
Sound* GetSound(unsigned int inID);
|
||||||
|
void UnloadSound(unsigned int inID);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ALCdevice* device;
|
ALCdevice* device;
|
||||||
|
|||||||
@@ -8,8 +8,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "WorldHandler.h"
|
#include "WorldHandler.h"
|
||||||
|
|
||||||
World::World(const std::string &fileName):
|
World::World(const std::string &fileName)
|
||||||
music_id(-1)
|
|
||||||
{
|
{
|
||||||
nextworld = false;
|
nextworld = false;
|
||||||
|
|
||||||
@@ -183,8 +182,8 @@ World::World(const std::string &fileName):
|
|||||||
|
|
||||||
if (!v["world"]["music"].isNull())
|
if (!v["world"]["music"].isNull())
|
||||||
{
|
{
|
||||||
music_id = CrystalPoint::GetSoundSystem().LoadSound(v["world"]["music"].asString().c_str(), true);
|
sound_id = CrystalPoint::GetSoundSystem().LoadSound(v["world"]["music"].asString().c_str(), true);
|
||||||
music = CrystalPoint::GetSoundSystem().GetSound(music_id);
|
music = CrystalPoint::GetSoundSystem().GetSound(sound_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!v["portal"].isNull())
|
if (!v["portal"].isNull())
|
||||||
@@ -218,7 +217,7 @@ World::~World()
|
|||||||
{
|
{
|
||||||
delete heightmap;
|
delete heightmap;
|
||||||
music->Stop();
|
music->Stop();
|
||||||
delete music;
|
CrystalPoint::GetSoundSystem().UnloadSound(sound_id);
|
||||||
delete skybox;
|
delete skybox;
|
||||||
delete portal;
|
delete portal;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user