Skip to content

Commit

Permalink
Fixed particle memory leak.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mntndew committed Jun 16, 2014
1 parent 4a25ba8 commit c2ece26
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions Client/Client/ParticleEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,37 @@ void ParticleEmitter::update(sf::Time & p_deltaTime){
m_vertexArray.append(m_particles[i].trail->getVertex());
}else
{
delete m_particles[i].trail;
m_particles.erase(m_particles.begin() + i);
}
}
}

void ParticleEmitter::Emit(const std::string & p_type, const sf::Vector2<float> & p_position, const sf::Vector2<float> & p_velocity){
Particle* particle = new Particle(p_type, ptr_particleLoader->getParticleType(p_type), p_position, p_velocity);
m_particles.push_back(*particle);
Particle particle = Particle(p_type, ptr_particleLoader->getParticleType(p_type), p_position, p_velocity);
m_particles.push_back(particle);
}

void ParticleEmitter::Emit(const std::string & p_type, const sf::Vector2<float> & p_position){
sf::Vector2<float> velocity = sf::Vector2<float>((((float)math::random(0, 100))/100)*(math::random(-1, 1, 0)), (((float)math::random(0, 100))/100)*(math::random(-1, 1, 0)));
Particle* particle = new Particle(p_type, ptr_particleLoader->getParticleType(p_type), p_position, velocity);
m_particles.push_back(*particle);
Particle particle = Particle(p_type, ptr_particleLoader->getParticleType(p_type), p_position, velocity);
m_particles.push_back(particle);
}

void ParticleEmitter::Emit(const std::string & p_type, const sf::Vector2<float> & p_position, const sf::Vector2<float> & p_velocity, const int & p_amount){
for (int i = 0; i < p_amount; i++)
{
Particle* particle = new Particle(p_type, ptr_particleLoader->getParticleType(p_type), p_position, p_velocity);
m_particles.push_back(*particle);
Particle particle = Particle(p_type, ptr_particleLoader->getParticleType(p_type), p_position, p_velocity);
m_particles.push_back(particle);
}
}

void ParticleEmitter::Emit(const std::string & p_type, const sf::Vector2<float> & p_position, const int & p_amount){
for (int i = 0; i < p_amount; i++)
{
sf::Vector2<float> velocity = sf::Vector2<float>(((((float)math::random(1, 100))/100)*(math::random(-1, 1, 0))), ((((float)math::random(1, 100))/100)*(math::random(-1, 1, 0))));
Particle* particle = new Particle(p_type, ptr_particleLoader->getParticleType(p_type), p_position, velocity);
m_particles.push_back(*particle);
Particle particle = Particle(p_type, ptr_particleLoader->getParticleType(p_type), p_position, velocity);
m_particles.push_back(particle);
}
}

Expand Down

0 comments on commit c2ece26

Please sign in to comment.