Sound pointers worden gedelete

This commit is contained in:
Aaldert
2016-06-21 14:45:41 +02:00
parent 6096e53d94
commit eadfea9d63
6 changed files with 16 additions and 9 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ Enemy::~Enemy()
if (model)
Model::unload(model);
delete music;
CrystalPoint::GetSoundSystem().UnloadSound(hit_sound_id);
}
void Enemy::draw()
+1 -2
View File
@@ -30,7 +30,7 @@ Portal::Portal(const std::string &fileName,
Portal::~Portal()
{
// Model::unload(model);
// delete music;
CrystalPoint::GetSoundSystem().UnloadSound(sound_id);
}
void Portal::collide()
@@ -46,7 +46,6 @@ bool Portal::enter(float deltaTime)
{
if (delay > 3 && started)
{
delete music;
delay = 0;
return true;
}
+8
View File
@@ -48,3 +48,11 @@ Sound* SoundSystem::GetSound(unsigned int inID)
return nullptr;
return sounds[inID];
}
void SoundSystem::UnloadSound(unsigned int inID)
{
if (inID > sounds.size())
return;
delete sounds[inID];
// sounds.erase[inID];
}
+1
View File
@@ -24,6 +24,7 @@ public:
unsigned int LoadSound(const char* inWavPath, bool inLooping);
Sound* GetSound(unsigned int inID);
void UnloadSound(unsigned int inID);
private:
ALCdevice* device;
+4 -5
View File
@@ -8,8 +8,7 @@
#include <algorithm>
#include "WorldHandler.h"
World::World(const std::string &fileName):
music_id(-1)
World::World(const std::string &fileName)
{
nextworld = false;
@@ -183,8 +182,8 @@ World::World(const std::string &fileName):
if (!v["world"]["music"].isNull())
{
music_id = CrystalPoint::GetSoundSystem().LoadSound(v["world"]["music"].asString().c_str(), true);
music = CrystalPoint::GetSoundSystem().GetSound(music_id);
sound_id = CrystalPoint::GetSoundSystem().LoadSound(v["world"]["music"].asString().c_str(), true);
music = CrystalPoint::GetSoundSystem().GetSound(sound_id);
}
if (!v["portal"].isNull())
@@ -218,7 +217,7 @@ World::~World()
{
delete heightmap;
music->Stop();
delete music;
CrystalPoint::GetSoundSystem().UnloadSound(sound_id);
delete skybox;
delete portal;
}
+1 -1
View File
@@ -27,7 +27,7 @@ private:
bool nextworld;
int music_id,maxCrystals,maxEnemies;
int sound_id,maxCrystals,maxEnemies;
std::vector<Entity*> entities;
std::vector<Enemy*> enemies;