Skip to content

Commit

Permalink
fix: Replace raw pointer with 'std::unique_ptr'
Browse files Browse the repository at this point in the history
  • Loading branch information
utilForever committed Sep 15, 2020
1 parent a8f5748 commit c59cb97
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Extensions/HellPython/Sources/Games/Game.cpp
Expand Up @@ -7,6 +7,8 @@
#include <Games/Game.hpp>
#include <HellSolver/Games/Game.hpp>

#include <pybind11/stl.h>

using namespace hell_solver;

void AddGame(pybind11::module& m)
Expand Down
3 changes: 2 additions & 1 deletion Includes/HellSolver/Games/Game.hpp
Expand Up @@ -10,6 +10,7 @@
#include <HellSolver/Games/Map.hpp>
#include <HellSolver/Player/Player.hpp>

#include <memory>
#include <string_view>

namespace hell_solver
Expand Down Expand Up @@ -47,7 +48,7 @@ class Game
private:
Map m_map;

Player* GamePlayer;
std::unique_ptr<Player> GamePlayer;

//! Checks an object can move.
//! \param dir The direction to move.
Expand Down
4 changes: 2 additions & 2 deletions Sources/HellSolver/Games/Game.cpp
Expand Up @@ -12,8 +12,8 @@ Game::Game(std::string_view filename)
{
m_map.Load(filename);
Position StartPoint = m_map.GetStartPoint();
GamePlayer = new Player(StartPoint.first, StartPoint.second,
m_map.GetInitMoveCount());
GamePlayer = std::make_unique<Player>(StartPoint.first, StartPoint.second,
m_map.GetInitMoveCount());
}

void Game::Reset()
Expand Down

0 comments on commit c59cb97

Please sign in to comment.