From b36d072ad7a7b9c6e30fcb25d6bbb001a8393468 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 10 Apr 2022 17:20:49 +0200 Subject: refactor: add factory class & make DI container return unique ptrs --- src/engine/engine.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/engine') diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index c988c33..a05fed9 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -9,8 +9,8 @@ CLIGameEngine::CLIGameEngine(IGameFactory game_factory, ISceneFactory scene_fact std::shared_ptr input_handler, std::shared_ptr cursor_controller, std::shared_ptr window) noexcept - : _game_factory(game_factory), - _scene_factory(scene_factory), + : _game_factory(std::move(game_factory)), + _scene_factory(std::move(scene_factory)), _input_handler(std::move(input_handler)), _cursor_controller(std::move(cursor_controller)), _window(std::move(window)) @@ -19,7 +19,7 @@ CLIGameEngine::CLIGameEngine(IGameFactory game_factory, ISceneFactory scene_fact void CLIGameEngine::start() noexcept { - auto scene = _scene_factory(_cursor_controller, _window); + std::shared_ptr scene = _scene_factory(_cursor_controller, _window); scene->enter(); _input_handler->enter_raw_mode(); @@ -29,7 +29,7 @@ void CLIGameEngine::start() noexcept game->on_start(); std::atexit(normalize_lambda( - [this, scene, game]() + [this, scene, &game]() { scene->leave(); _input_handler->leave_raw_mode(); -- cgit v1.2.3-18-g5258