Skip to content

Commit

Permalink
CScreensaverPyro: use std::vector for m_projectiles
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Rusak <[email protected]>
  • Loading branch information
lrusak committed Apr 26, 2023
1 parent 1bfc837 commit d98b7b6
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Pyro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
#endif

#include "Pyro.h"

#include <vector>

#include <stdio.h>
#include <math.h>
#include <stddef.h>
Expand Down Expand Up @@ -129,7 +132,7 @@ class ATTR_DLL_LOCAL CScreensaverPyro
int m_iWidth;
int m_iHeight;

struct projectile *m_projectiles;
std::vector<projectile> m_projectiles;
struct projectile *m_free_projectiles;

int m_how_many;
Expand Down Expand Up @@ -171,9 +174,10 @@ CScreensaverPyro::CScreensaverPyro()
bool CScreensaverPyro::Start()
{
m_free_projectiles = nullptr;
m_projectiles = static_cast<struct projectile*>(calloc(m_how_many, sizeof (struct projectile)));
for (int i = 0; i < m_how_many; i++)
free_projectile(&m_projectiles[i]);
m_projectiles.resize(m_how_many);

for (auto& projectile : m_projectiles)
free_projectile(&projectile);

#ifndef WIN32
std::string fraqShader = kodi::addon::GetAddonPath("resources/shaders/" GL_TYPE_STRING "/frag.glsl");
Expand Down Expand Up @@ -265,7 +269,6 @@ void CScreensaverPyro::Render()
// any resources we have created.
void CScreensaverPyro::Stop()
{
free(m_projectiles);
#ifndef WIN32
glDeleteBuffers(1, &m_vertexVBO);
m_vertexVBO = 0;
Expand Down

0 comments on commit d98b7b6

Please sign in to comment.