Skip to content

Commit

Permalink
main: make m_asteroids a unique_ptr
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 47f0c1b commit 4f7bc86
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 2 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ const BYTE PixelShader[] =
#endif

CMyAddon::CMyAddon()
: m_asteroids(nullptr),
m_timer(nullptr)
: m_timer(nullptr)
{
}

Expand Down Expand Up @@ -127,9 +126,7 @@ bool CMyAddon::Start()
m_Height = Height();

srand((u32)time(nullptr));
m_asteroids = new CAsteroids(this);
if (!m_asteroids)
return false;
m_asteroids = std::make_unique<CAsteroids>(this);

m_timer = new CTimer();
m_timer->Init();
Expand Down Expand Up @@ -179,7 +176,6 @@ void CMyAddon::Stop()
#endif

m_asteroids->InvalidateDevice();
SAFE_DELETE(m_asteroids);
SAFE_DELETE(m_timer);

#ifndef WIN32
Expand Down
4 changes: 3 additions & 1 deletion src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <d3d11.h>
#endif

#include <memory>

#include <stdio.h>
#include <stdlib.h>
#include "types.h"
Expand Down Expand Up @@ -83,7 +85,7 @@ class ATTR_DLL_LOCAL CMyAddon
ID3D11PixelShader* m_pPShader;
#endif

CAsteroids* m_asteroids;
std::unique_ptr<CAsteroids> m_asteroids;
CTimer* m_timer;
};

Expand Down

0 comments on commit 4f7bc86

Please sign in to comment.