From 8533be8d5cf546d4a0af4541c0d2bacbfd3e4e86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kapu=C5=9Bci=C5=84ski?= Date: Sat, 26 Feb 2022 18:48:51 +0100 Subject: [PATCH] Replaced MakeUnique and MakeUniqueArray with std::make_unique --- src/CMakeLists.txt | 1 - src/app/app.cpp | 35 +++-- src/app/controller.cpp | 5 +- src/app/main.cpp | 3 +- src/app/pausemanager.cpp | 2 +- src/app/pausemanager.h | 2 - src/common/config_file.cpp | 9 +- src/common/event.h | 13 +- src/common/font_loader.cpp | 3 +- src/common/image.cpp | 8 +- src/common/make_unique.h | 48 ------- src/common/resources/inputstreambuffer.cpp | 4 +- src/common/resources/outputstreambuffer.cpp | 4 +- src/common/resources/resourcemanager.cpp | 7 +- src/common/resources/sdl_memory_wrapper.cpp | 3 +- src/common/system/system.cpp | 10 +- src/common/thread/worker_thread.h | 2 - src/graphics/engine/engine.cpp | 27 ++-- src/graphics/engine/pyro_manager.cpp | 4 +- src/graphics/engine/terrain.cpp | 2 +- src/graphics/engine/text.cpp | 2 +- src/graphics/opengl/gl33device.cpp | 7 +- src/graphics/opengl/glutil.cpp | 17 ++- src/graphics/opengl/glutil.h | 4 +- src/level/parser/parser.cpp | 7 +- src/level/parser/parser.h | 4 +- src/level/parser/parserline.cpp | 3 +- src/level/parser/parserparam.cpp | 21 ++- src/level/player_profile.cpp | 15 +-- src/level/robotmain.cpp | 125 +++++++++--------- src/object/auto/auto.cpp | 11 +- src/object/auto/autoconvert.cpp | 10 +- src/object/auto/autoderrick.cpp | 10 +- src/object/auto/autodestroyer.cpp | 10 +- src/object/auto/autoegg.cpp | 16 +-- src/object/auto/autofactory.cpp | 10 +- src/object/auto/autolabo.cpp | 12 +- src/object/auto/automush.cpp | 10 +- src/object/auto/autonest.cpp | 10 +- src/object/auto/autonuclearplant.cpp | 10 +- src/object/auto/autopowercaptor.cpp | 10 +- src/object/auto/autopowerplant.cpp | 10 +- src/object/auto/autorepair.cpp | 10 +- src/object/auto/autoresearch.cpp | 11 +- src/object/auto/autotower.cpp | 20 ++- src/object/auto/autovault.cpp | 10 +- .../implementation/program_storage_impl.cpp | 18 +-- .../implementation/programmable_impl.cpp | 2 +- .../implementation/task_executor_impl.cpp | 4 +- src/object/motion/motion.cpp | 8 +- src/object/object_factory.cpp | 34 +++-- src/object/object_manager.cpp | 3 +- src/object/old_object.cpp | 51 ++++--- src/object/subclass/base_alien.cpp | 18 ++- src/object/subclass/base_building.cpp | 40 +++--- src/object/subclass/base_robot.cpp | 14 +- src/object/subclass/exchange_post.cpp | 15 +-- src/object/subclass/shielder.cpp | 10 +- src/object/subclass/static_object.cpp | 4 +- src/object/task/taskgoto.cpp | 5 +- src/physics/physics.cpp | 7 +- src/script/script.cpp | 6 +- src/script/scriptfunc.cpp | 11 +- src/sound/oalsound/alsound.cpp | 14 +- src/ui/controls/edit.cpp | 3 +- src/ui/controls/editvalue.cpp | 7 +- src/ui/controls/interface.cpp | 6 +- src/ui/controls/list.cpp | 6 +- src/ui/controls/scroll.cpp | 5 +- src/ui/controls/slider.cpp | 4 +- src/ui/controls/window.cpp | 10 +- src/ui/maindialog.cpp | 1 - src/ui/mainui.cpp | 35 +++-- src/ui/object_interface.cpp | 2 +- src/ui/studio.cpp | 4 +- test/unit/app/app_test.cpp | 6 +- 76 files changed, 392 insertions(+), 538 deletions(-) delete mode 100644 src/common/make_unique.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 376d9d35..027bcd36 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -49,7 +49,6 @@ add_library(colobotbase STATIC common/language.h common/logger.cpp common/logger.h - common/make_unique.h common/profiler.cpp common/profiler.h common/regex_utils.cpp diff --git a/src/app/app.cpp b/src/app/app.cpp index cae2352e..10559bf4 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -28,7 +28,6 @@ #include "common/image.h" #include "common/key.h" #include "common/logger.h" -#include "common/make_unique.h" #include "common/profiler.h" #include "common/stringutils.h" #include "common/version.h" @@ -111,11 +110,11 @@ struct ApplicationPrivate CApplication::CApplication(CSystemUtils* systemUtils) : m_systemUtils(systemUtils), - m_private(MakeUnique()), - m_configFile(MakeUnique()), - m_input(MakeUnique()), - m_pathManager(MakeUnique(systemUtils)), - m_modManager(MakeUnique(this, m_pathManager.get())) + m_private(std::make_unique()), + m_configFile(std::make_unique()), + m_input(std::make_unique()), + m_pathManager(std::make_unique(systemUtils)), + m_modManager(std::make_unique(this, m_pathManager.get())) { m_exitCode = 0; m_active = false; @@ -514,11 +513,11 @@ bool CApplication::Create() #ifdef OPENAL_SOUND if (!m_headless) { - m_sound = MakeUnique(); + m_sound = std::make_unique(); } else { - m_sound = MakeUnique(); + m_sound = std::make_unique(); } #else GetLogger()->Info("No sound support.\n"); @@ -536,7 +535,7 @@ bool CApplication::Create() /* SDL initialization sequence */ // Creating the m_engine now because it holds the vsync flag - m_engine = MakeUnique(this, m_systemUtils); + m_engine = std::make_unique(this, m_systemUtils); Uint32 initFlags = SDL_INIT_VIDEO | SDL_INIT_TIMER; @@ -689,10 +688,10 @@ bool CApplication::Create() return false; } - m_eventQueue = MakeUnique(); + m_eventQueue = std::make_unique(); // Create the robot application. - m_controller = MakeUnique(); + m_controller = std::make_unique(); StartLoadingMusic(); @@ -1247,7 +1246,7 @@ Event CApplication::ProcessSystemEvent() else event.type = EVENT_KEY_UP; - auto data = MakeUnique(); + auto data = std::make_unique(); data->virt = false; data->key = m_private->currentEvent.key.keysym.sym; @@ -1270,7 +1269,7 @@ Event CApplication::ProcessSystemEvent() else if (m_private->currentEvent.type == SDL_TEXTINPUT) { event.type = EVENT_TEXT_INPUT; - auto data = MakeUnique(); + auto data = std::make_unique(); data->text = m_private->currentEvent.text.text; event.data = std::move(data); } @@ -1278,7 +1277,7 @@ Event CApplication::ProcessSystemEvent() { event.type = EVENT_MOUSE_WHEEL; - auto data = MakeUnique(); + auto data = std::make_unique(); data->y = m_private->currentEvent.wheel.y; data->x = m_private->currentEvent.wheel.x; @@ -1287,7 +1286,7 @@ Event CApplication::ProcessSystemEvent() else if ( (m_private->currentEvent.type == SDL_MOUSEBUTTONDOWN) || (m_private->currentEvent.type == SDL_MOUSEBUTTONUP) ) { - auto data = MakeUnique(); + auto data = std::make_unique(); if (m_private->currentEvent.type == SDL_MOUSEBUTTONDOWN) event.type = EVENT_MOUSE_BUTTON_DOWN; @@ -1308,7 +1307,7 @@ Event CApplication::ProcessSystemEvent() { event.type = EVENT_JOY_AXIS; - auto data = MakeUnique(); + auto data = std::make_unique(); data->axis = m_private->currentEvent.jaxis.axis; data->value = m_private->currentEvent.jaxis.value; event.data = std::move(data); @@ -1321,7 +1320,7 @@ Event CApplication::ProcessSystemEvent() else event.type = EVENT_JOY_BUTTON_UP; - auto data = MakeUnique(); + auto data = std::make_unique(); data->button = m_private->currentEvent.jbutton.button; event.data = std::move(data); } @@ -1449,7 +1448,7 @@ Event CApplication::CreateVirtualEvent(const Event& sourceEvent) auto sourceData = sourceEvent.GetData(); - auto data = MakeUnique(); + auto data = std::make_unique(); data->virt = true; data->key = VIRTUAL_JOY(sourceData->button); virtualEvent.data = std::move(data); diff --git a/src/app/controller.cpp b/src/app/controller.cpp index a07a27b7..5a6928af 100644 --- a/src/app/controller.cpp +++ b/src/app/controller.cpp @@ -19,16 +19,13 @@ #include "app/controller.h" - -#include "common/make_unique.h" - #include "level/robotmain.h" CController::CController() { - m_main = MakeUnique(); + m_main = std::make_unique(); } CController::~CController() diff --git a/src/app/main.cpp b/src/app/main.cpp index b20a6b2f..d21d97f9 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -28,7 +28,6 @@ #include "app/signal_handlers.h" #include "common/logger.h" -#include "common/make_unique.h" #include "common/profiler.h" #include "common/restext.h" #include "common/version.h" @@ -150,7 +149,7 @@ int main(int argc, char *argv[]) windowsArgs.push_back(std::move(argVec)); } - auto windowsArgvPtrs = MakeUniqueArray(wargc); + auto windowsArgvPtrs = std::make_unique(wargc); for (int i = 0; i < wargc; i++) windowsArgvPtrs[i] = windowsArgs[i].data(); diff --git a/src/app/pausemanager.cpp b/src/app/pausemanager.cpp index 9fdb8839..a7bfdd3e 100644 --- a/src/app/pausemanager.cpp +++ b/src/app/pausemanager.cpp @@ -65,7 +65,7 @@ CPauseManager::~CPauseManager() ActivePause* CPauseManager::ActivatePause(PauseType type, PauseMusic music) { GetLogger()->Debug("Activated pause mode - %s\n", GetPauseName(type).c_str()); - auto pause = MakeUnique(type, music); + auto pause = std::make_unique(type, music); ActivePause* ptr = pause.get(); m_activePause.push_back(std::move(pause)); Update(); diff --git a/src/app/pausemanager.h b/src/app/pausemanager.h index bbad78c0..169d364a 100644 --- a/src/app/pausemanager.h +++ b/src/app/pausemanager.h @@ -23,8 +23,6 @@ */ #pragma once -#include "common/make_unique.h" - #include #include #include diff --git a/src/common/config_file.cpp b/src/common/config_file.cpp index d1c9f694..9954647b 100644 --- a/src/common/config_file.cpp +++ b/src/common/config_file.cpp @@ -21,7 +21,6 @@ #include "common/config_file.h" #include "common/logger.h" -#include "common/make_unique.h" #include "common/resources/inputstream.h" #include "common/resources/outputstream.h" @@ -66,13 +65,13 @@ bool CConfigFile::Init() bool good; if (m_useCurrentDirectory) { - auto inputStream = MakeUnique("./colobot.ini"); + auto inputStream = std::make_unique("./colobot.ini"); good = inputStream->good(); stream = std::move(inputStream); } else { - auto inputStream = MakeUnique("colobot.ini"); + auto inputStream = std::make_unique("colobot.ini"); good = inputStream->is_open(); stream = std::move(inputStream); } @@ -106,13 +105,13 @@ bool CConfigFile::Save() bool good; if (m_useCurrentDirectory) { - auto outputStream = MakeUnique("./colobot.ini"); + auto outputStream = std::make_unique("./colobot.ini"); good = outputStream->good(); stream = std::move(outputStream); } else { - auto outputStream = MakeUnique("colobot.ini"); + auto outputStream = std::make_unique("colobot.ini"); good = outputStream->is_open(); stream = std::move(outputStream); } diff --git a/src/common/event.h b/src/common/event.h index f887e604..39b7582c 100644 --- a/src/common/event.h +++ b/src/common/event.h @@ -25,7 +25,6 @@ #pragma once #include "common/key.h" -#include "common/make_unique.h" #include @@ -663,7 +662,7 @@ struct KeyEventData : public EventData { std::unique_ptr Clone() const override { - return MakeUnique(*this); + return std::make_unique(*this); } //! If true, the key is a virtual code generated by certain key modifiers or joystick buttons @@ -682,7 +681,7 @@ struct KeyEventData : public EventData { std::unique_ptr Clone() const override { - return MakeUnique(*this); + return std::make_unique(*this); } //! Text entered by the user (usually one character, UTF-8 encoded) @@ -712,7 +711,7 @@ struct MouseButtonEventData : public EventData { std::unique_ptr Clone() const override { - return MakeUnique(*this); + return std::make_unique(*this); } //! The mouse button @@ -727,7 +726,7 @@ struct MouseWheelEventData : public EventData { std::unique_ptr Clone() const override { - return MakeUnique(*this); + return std::make_unique(*this); } //! Amount scrolled vertically, positive value is away from the user @@ -744,7 +743,7 @@ struct JoyAxisEventData : public EventData { std::unique_ptr Clone() const override { - return MakeUnique(*this); + return std::make_unique(*this); } //! The joystick axis index @@ -761,7 +760,7 @@ struct JoyButtonEventData : public EventData { std::unique_ptr Clone() const override { - return MakeUnique(*this); + return std::make_unique(*this); } //! The joystick button index diff --git a/src/common/font_loader.cpp b/src/common/font_loader.cpp index 9cb3eaeb..7f42f666 100644 --- a/src/common/font_loader.cpp +++ b/src/common/font_loader.cpp @@ -20,7 +20,6 @@ #include "common/font_loader.h" #include "common/logger.h" -#include "common/make_unique.h" #include "common/resources/inputstream.h" #include "common/resources/outputstream.h" @@ -52,7 +51,7 @@ bool CFontLoader::Init() try { std::unique_ptr stream; - auto inputStream = MakeUnique("/fonts/fonts.ini"); + auto inputStream = std::make_unique("/fonts/fonts.ini"); bool good = inputStream->is_open(); stream = std::move(inputStream); diff --git a/src/common/image.cpp b/src/common/image.cpp index b3a3594f..8ba5bc76 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -20,8 +20,6 @@ #include "common/image.h" -#include "common/make_unique.h" - #include "common/resources/outputstream.h" #include "common/resources/resourcemanager.h" @@ -147,7 +145,7 @@ bool PNGSaveSurface(const char *filename, SDL_Surface *surf) png_write_info(pngPtr, infoPtr); png_set_packing(pngPtr); - auto rowPointers = MakeUniqueArray(surf->h); + auto rowPointers = std::make_unique(surf->h); for (int i = 0; i < surf->h; i++) rowPointers[i] = static_cast( static_cast(surf->pixels) ) + i*surf->pitch; png_write_image(pngPtr, rowPointers.get()); @@ -171,7 +169,7 @@ CImage::CImage() CImage::CImage(const glm::ivec2& size) { - m_data = MakeUnique(); + m_data = std::make_unique(); m_data->surface = SDL_CreateRGBSurface(0, size.x, size.y, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000); } @@ -395,7 +393,7 @@ bool CImage::Load(const std::string& fileName) if (! IsEmpty() ) Free(); - m_data = MakeUnique(); + m_data = std::make_unique(); m_error = ""; diff --git a/src/common/make_unique.h b/src/common/make_unique.h deleted file mode 100644 index d8c3b3fb..00000000 --- a/src/common/make_unique.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This file is part of the Colobot: Gold Edition source code - * Copyright (C) 2001-2021, Daniel Roux, EPSITEC SA & TerranovaTeam - * http://epsitec.ch; http://colobot.info; http://github.com/colobot - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://gnu.org/licenses - */ - -#pragma once - -#include -#include - - -/** - * A template function to make std::unique_ptr without naked new - * It can be replaced with std::make_unique once we use C++14 - */ -template -inline std::unique_ptr MakeUnique(Args&&... args) -{ - //@colobot-lint-exclude NakedNewRule - return std::unique_ptr(new T(std::forward(args)...)); - //@end-colobot-lint-exclude -} - -/** - * A template function to make std::unique_ptr of array type without naked new - * It can be replaced with std::make_unique once we use C++14 - */ -template -inline std::unique_ptr MakeUniqueArray(std::size_t size) -{ - //@colobot-lint-exclude NakedNewRule - return std::unique_ptr(new T[size]()); - //@end-colobot-lint-exclude -} diff --git a/src/common/resources/inputstreambuffer.cpp b/src/common/resources/inputstreambuffer.cpp index 3c5bfea1..4df9ea97 100644 --- a/src/common/resources/inputstreambuffer.cpp +++ b/src/common/resources/inputstreambuffer.cpp @@ -19,8 +19,6 @@ #include "common/resources/inputstreambuffer.h" -#include "common/make_unique.h" - #include "common/resources/resourcemanager.h" #include @@ -35,7 +33,7 @@ CInputStreamBuffer::CInputStreamBuffer(std::size_t bufferSize) throw std::runtime_error("File buffer must be larger than 0 bytes"); } - m_buffer = MakeUniqueArray(bufferSize); + m_buffer = std::make_unique(bufferSize); } diff --git a/src/common/resources/outputstreambuffer.cpp b/src/common/resources/outputstreambuffer.cpp index 0db059f3..8e24d1c9 100644 --- a/src/common/resources/outputstreambuffer.cpp +++ b/src/common/resources/outputstreambuffer.cpp @@ -19,8 +19,6 @@ #include "common/resources/outputstreambuffer.h" -#include "common/make_unique.h" - #include "common/resources/resourcemanager.h" #include @@ -34,7 +32,7 @@ COutputStreamBuffer::COutputStreamBuffer(std::size_t bufferSize) throw std::runtime_error("File buffer must be larger then 0 bytes"); } - m_buffer = MakeUniqueArray(bufferSize); + m_buffer = std::make_unique(bufferSize); setp(m_buffer.get(), m_buffer.get() + bufferSize); } diff --git a/src/common/resources/resourcemanager.cpp b/src/common/resources/resourcemanager.cpp index 0facda71..9cfe5770 100644 --- a/src/common/resources/resourcemanager.cpp +++ b/src/common/resources/resourcemanager.cpp @@ -27,7 +27,6 @@ #endif #include "common/logger.h" -#include "common/make_unique.h" #include @@ -124,17 +123,17 @@ std::string CResourceManager::GetSaveLocation() std::unique_ptr CResourceManager::GetSDLFileHandler(const std::string &filename) { - return MakeUnique(CleanPath(filename)); + return std::make_unique(CleanPath(filename)); } std::unique_ptr CResourceManager::GetSDLMemoryHandler(const std::string &filename) { - return MakeUnique(CleanPath(filename)); + return std::make_unique(CleanPath(filename)); } std::unique_ptr CResourceManager::GetSNDFileHandler(const std::string &filename) { - return MakeUnique(CleanPath(filename)); + return std::make_unique(CleanPath(filename)); } diff --git a/src/common/resources/sdl_memory_wrapper.cpp b/src/common/resources/sdl_memory_wrapper.cpp index 77d81d66..490a14d3 100644 --- a/src/common/resources/sdl_memory_wrapper.cpp +++ b/src/common/resources/sdl_memory_wrapper.cpp @@ -21,7 +21,6 @@ #include "common/resources/sdl_memory_wrapper.h" #include "common/logger.h" -#include "common/make_unique.h" #include @@ -45,7 +44,7 @@ CSDLMemoryWrapper::CSDLMemoryWrapper(const std::string& filename) } PHYSFS_sint64 length = PHYSFS_fileLength(file); - m_buffer = MakeUniqueArray(length); + m_buffer = std::make_unique(length); if (PHYSFS_read(file, m_buffer.get(), 1, length) != length) { GetLogger()->Error("Unable to read data for \"%s\"\n", filename.c_str()); diff --git a/src/common/system/system.cpp b/src/common/system/system.cpp index d62ecf78..c97d35a8 100644 --- a/src/common/system/system.cpp +++ b/src/common/system/system.cpp @@ -20,8 +20,6 @@ #include "common/system/system.h" -#include "common/make_unique.h" - #if defined(PLATFORM_WINDOWS) #include "common/system/system_windows.h" #elif defined(PLATFORM_LINUX) @@ -43,13 +41,13 @@ std::unique_ptr CSystemUtils::Create() { std::unique_ptr instance; #if defined(PLATFORM_WINDOWS) - instance = MakeUnique(); + instance = std::make_unique(); #elif defined(PLATFORM_LINUX) - instance = MakeUnique(); + instance = std::make_unique(); #elif defined(PLATFORM_MACOSX) - instance = MakeUnique(); + instance = std::make_unique(); #else - instance = MakeUnique(); + instance = std::make_unique(); #endif return instance; } diff --git a/src/common/thread/worker_thread.h b/src/common/thread/worker_thread.h index b62dc49b..c6d6f92c 100644 --- a/src/common/thread/worker_thread.h +++ b/src/common/thread/worker_thread.h @@ -19,8 +19,6 @@ #pragma once -#include "common/make_unique.h" - #include #include #include diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index 6593d5f5..351bbded 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -26,7 +26,6 @@ #include "common/image.h" #include "common/key.h" #include "common/logger.h" -#include "common/make_unique.h" #include "common/profiler.h" #include "common/stringutils.h" @@ -375,15 +374,15 @@ bool CEngine::Create() SetMultiSample(m_multisample); SetVSync(m_vsync); - m_modelManager = MakeUnique(this); - m_pyroManager = MakeUnique(); - m_lightMan = MakeUnique(this); - m_text = MakeUnique(this); - m_particle = MakeUnique(this); - m_water = MakeUnique(this); - m_cloud = MakeUnique(this); - m_lightning = MakeUnique(this); - m_planet = MakeUnique(this); + m_modelManager = std::make_unique(this); + m_pyroManager = std::make_unique(); + m_lightMan = std::make_unique(this); + m_text = std::make_unique(this); + m_particle = std::make_unique(this); + m_water = std::make_unique(this); + m_cloud = std::make_unique(this); + m_lightning = std::make_unique(this); + m_planet = std::make_unique(this); m_lightMan->SetDevice(m_device); m_particle->SetDevice(m_device); @@ -544,8 +543,8 @@ void CEngine::FrameUpdate() void CEngine::WriteScreenShot(const std::string& fileName) { - auto data = MakeUnique(); - data->img = MakeUnique(glm::ivec2(m_size.x, m_size.y)); + auto data = std::make_unique(); + data->img = std::make_unique(glm::ivec2(m_size.x, m_size.y)); auto pixels = m_device->GetFrameBufferPixels(); data->img->SetDataPixels(pixels->GetPixelsData()); @@ -3040,7 +3039,7 @@ void CEngine::Capture3DScene() // calculate 2nd mipmap int newWidth = width / 4; int newHeight = height / 4; - std::unique_ptr mipmap = MakeUniqueArray(4 * newWidth * newHeight); + std::unique_ptr mipmap = std::make_unique(4 * newWidth * newHeight); for (int x = 0; x < newWidth; x++) { @@ -3069,7 +3068,7 @@ void CEngine::Capture3DScene() } // calculate Gaussian blur - std::unique_ptr blured = MakeUniqueArray(4 * newWidth * newHeight); + std::unique_ptr blured = std::make_unique(4 * newWidth * newHeight); float matrix[7][7] = { diff --git a/src/graphics/engine/pyro_manager.cpp b/src/graphics/engine/pyro_manager.cpp index dee44536..fae1c3d5 100644 --- a/src/graphics/engine/pyro_manager.cpp +++ b/src/graphics/engine/pyro_manager.cpp @@ -19,8 +19,6 @@ #include "graphics/engine/pyro_manager.h" -#include "common/make_unique.h" - #include "graphics/engine/pyro.h" namespace Gfx @@ -35,7 +33,7 @@ CPyroManager::~CPyroManager() void Gfx::CPyroManager::Create(PyroType type, CObject* obj, float force) { - auto pyroUPtr = MakeUnique(); + auto pyroUPtr = std::make_unique(); pyroUPtr->Create(type, obj, force); m_pyros.insert(std::move(pyroUPtr)); } diff --git a/src/graphics/engine/terrain.cpp b/src/graphics/engine/terrain.cpp index ab1641a0..88393840 100644 --- a/src/graphics/engine/terrain.cpp +++ b/src/graphics/engine/terrain.cpp @@ -361,7 +361,7 @@ bool CTerrain::RandomizeRelief() for(int i = 0; i < octaveCount; i++) { int pxCount = static_cast(pow(2, (i+1)*2)); - octaves[i] = MakeUniqueArray(pxCount); + octaves[i] = std::make_unique(pxCount); for(int j = 0; j < pxCount; j++) { octaves[i][j] = Math::Rand(); diff --git a/src/graphics/engine/text.cpp b/src/graphics/engine/text.cpp index 38be55fd..397999d2 100644 --- a/src/graphics/engine/text.cpp +++ b/src/graphics/engine/text.cpp @@ -385,7 +385,7 @@ CText::CText(CEngine* engine) m_fontsCache = std::make_unique(); - m_quadBatch = MakeUnique(*engine); + m_quadBatch = std::make_unique(*engine); } CText::~CText() diff --git a/src/graphics/opengl/gl33device.cpp b/src/graphics/opengl/gl33device.cpp index a2d14b2e..0de13520 100644 --- a/src/graphics/opengl/gl33device.cpp +++ b/src/graphics/opengl/gl33device.cpp @@ -24,7 +24,6 @@ #include "common/config_file.h" #include "common/image.h" #include "common/logger.h" -#include "common/make_unique.h" #include "graphics/core/light.h" #include "graphics/core/material.h" @@ -206,7 +205,7 @@ bool CGL33Device::Create() framebufferParams.height = m_config.size.y; framebufferParams.depth = m_config.depthSize; - m_framebuffers["default"] = MakeUnique(framebufferParams); + m_framebuffers["default"] = std::make_unique(framebufferParams); GetLogger()->Info("CDevice created successfully\n"); @@ -254,7 +253,7 @@ void CGL33Device::ConfigChanged(const DeviceConfig& newConfig) framebufferParams.height = m_config.size.y; framebufferParams.depth = m_config.depthSize; - m_framebuffers["default"] = MakeUnique(framebufferParams); + m_framebuffers["default"] = std::make_unique(framebufferParams); } void CGL33Device::BeginScene() @@ -644,7 +643,7 @@ CFramebuffer* CGL33Device::CreateFramebuffer(std::string name, const Framebuffer return nullptr; } - auto framebuffer = MakeUnique(params); + auto framebuffer = std::make_unique(params); if (!framebuffer->Create()) return nullptr; CFramebuffer* framebufferPtr = framebuffer.get(); diff --git a/src/graphics/opengl/glutil.cpp b/src/graphics/opengl/glutil.cpp index f4ba87d6..11f99c9b 100644 --- a/src/graphics/opengl/glutil.cpp +++ b/src/graphics/opengl/glutil.cpp @@ -21,7 +21,6 @@ #include "common/image.h" #include "common/logger.h" -#include "common/make_unique.h" #include "graphics/opengl/gl33device.h" @@ -69,14 +68,14 @@ FramebufferSupport DetectFramebufferSupport() std::unique_ptr CreateDevice(const DeviceConfig &config, const std::string& name) { - if (name == "default") return MakeUnique(config); - else if (name == "opengl") return MakeUnique(config); - else if (name == "gl33") return MakeUnique(config); + if (name == "default") return std::make_unique(config); + else if (name == "opengl") return std::make_unique(config); + else if (name == "gl33") return std::make_unique(config); else if (name == "auto") { int version = GetOpenGLVersion(); - if (version >= 33) return MakeUnique(config); + if (version >= 33) return std::make_unique(config); } return nullptr; @@ -462,7 +461,7 @@ GLint CreateShader(GLint type, const std::vector& sources) GLint len; glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &len); - auto message = MakeUniqueArray(len + 1); + auto message = std::make_unique(len + 1); glGetShaderInfoLog(shader, len + 1, nullptr, message.get()); GetLogger()->Error("Shader compilation error occurred!\n%s\n", message.get()); @@ -507,7 +506,7 @@ GLint LoadShader(GLint type, const char* filename) GLint len; glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &len); - auto message = MakeUniqueArray(len + 1); + auto message = std::make_unique(len + 1); glGetShaderInfoLog(shader, len + 1, nullptr, message.get()); GetLogger()->Error("Shader compilation error occurred!\n%s\n", message.get()); @@ -540,7 +539,7 @@ GLint LinkProgram(int count, const GLint* shaders) GLint len; glGetProgramiv(program, GL_INFO_LOG_LENGTH, &len); - auto message = MakeUniqueArray(len + 1); + auto message = std::make_unique(len + 1); glGetProgramInfoLog(program, len + 1, nullptr, message.get()); GetLogger()->Error("Shader program linking error occurred!\n%s\n", message.get()); @@ -590,7 +589,7 @@ GLint LinkProgram(const std::vector& shaders) std::unique_ptr GetGLFrameBufferPixels(const glm::ivec2& size) { - auto pixels = MakeUnique(4 * size.x * size.y); + auto pixels = std::make_unique(4 * size.x * size.y); glReadPixels(0, 0, size.x, size.y, GL_RGBA, GL_UNSIGNED_BYTE, pixels->GetPixelsData()); diff --git a/src/graphics/opengl/glutil.h b/src/graphics/opengl/glutil.h index 0a3aba20..d9fe44b4 100644 --- a/src/graphics/opengl/glutil.h +++ b/src/graphics/opengl/glutil.h @@ -22,8 +22,6 @@ // config.h must be included first #include "common/config.h" -#include "common/make_unique.h" - #include "graphics/core/device.h" #include @@ -117,7 +115,7 @@ class CGLFrameBufferPixels : public CFrameBufferPixels { public: CGLFrameBufferPixels(std::size_t size) - : m_pixels(MakeUniqueArray(size)) + : m_pixels(std::make_unique(size)) {} void* GetPixelsData() override diff --git a/src/level/parser/parser.cpp b/src/level/parser/parser.cpp index 73227866..8c716638 100644 --- a/src/level/parser/parser.cpp +++ b/src/level/parser/parser.cpp @@ -21,7 +21,6 @@ #include "app/app.h" -#include "common/make_unique.h" #include "common/stringutils.h" #include "common/resources/inputstream.h" @@ -209,7 +208,7 @@ void CLevelParser::Load() if (command.empty()) continue; - auto parserLine = MakeUnique(lineNumber, command); + auto parserLine = std::make_unique(lineNumber, command); parserLine->SetLevel(this); if (command.length() > 2 && command[command.length() - 2] == '.') @@ -281,7 +280,7 @@ void CLevelParser::Load() std::string paramValue = line.substr(0, pos + 1); boost::algorithm::trim(paramValue); - parserLine->AddParam(paramName, MakeUnique(paramName, paramValue)); + parserLine->AddParam(paramName, std::make_unique(paramName, paramValue)); if (pos == std::string::npos) break; @@ -294,7 +293,7 @@ void CLevelParser::Load() std::string cmd = parserLine->GetCommand().substr(1, std::string::npos); if(cmd == "Include") { - std::unique_ptr includeParser = MakeUnique(parserLine->GetParam("file")->AsPath("")); + std::unique_ptr includeParser = std::make_unique(parserLine->GetParam("file")->AsPath("")); includeParser->Load(); for(CLevelParserLineUPtr& line : includeParser->m_lines) { diff --git a/src/level/parser/parser.h b/src/level/parser/parser.h index 99b5f9bf..c0108089 100644 --- a/src/level/parser/parser.h +++ b/src/level/parser/parser.h @@ -24,8 +24,6 @@ #pragma once -#include "common/make_unique.h" - #include "level/level_category.h" #include "level/robotmain.h" @@ -106,7 +104,7 @@ private: inline std::string InjectLevelPathsForCurrentLevel(const std::string& path, const std::string& defaultDir = "") { CRobotMain* main = CRobotMain::GetInstancePointer(); - auto levelParser = MakeUnique(); + auto levelParser = std::make_unique(); levelParser->SetLevelPaths(main->GetLevelCategory(), main->GetLevelChap(), main->GetLevelRank()); return levelParser->InjectLevelPaths(path, defaultDir); } diff --git a/src/level/parser/parserline.cpp b/src/level/parser/parserline.cpp index 4e3fe452..180a4626 100644 --- a/src/level/parser/parserline.cpp +++ b/src/level/parser/parserline.cpp @@ -20,7 +20,6 @@ #include "level/parser/parserline.h" #include "common/logger.h" -#include "common/make_unique.h" #include "level/parser/parser.h" @@ -82,7 +81,7 @@ CLevelParserParam* CLevelParserLine::GetParam(std::string name) return it->second.get(); } - auto paramUPtr = MakeUnique(name, true); + auto paramUPtr = std::make_unique(name, true); paramUPtr->SetLine(this); CLevelParserParam* paramPtr = paramUPtr.get(); m_params.insert(std::make_pair(name, std::move(paramUPtr))); diff --git a/src/level/parser/parserparam.cpp b/src/level/parser/parserparam.cpp index 24001122..ff09728b 100644 --- a/src/level/parser/parserparam.cpp +++ b/src/level/parser/parserparam.cpp @@ -22,7 +22,6 @@ #include "app/app.h" #include "common/logger.h" -#include "common/make_unique.h" #include "common/stringutils.h" #include "common/resources/resourcemanager.h" @@ -67,28 +66,28 @@ CLevelParserParam::CLevelParserParam(bool value) CLevelParserParam::CLevelParserParam(Gfx::Color value) { - m_array.push_back(MakeUnique(value.r)); - m_array.push_back(MakeUnique(value.g)); - m_array.push_back(MakeUnique(value.b)); - m_array.push_back(MakeUnique(value.a)); + m_array.push_back(std::make_unique(value.r)); + m_array.push_back(std::make_unique(value.g)); + m_array.push_back(std::make_unique(value.b)); + m_array.push_back(std::make_unique(value.a)); LoadArray(); } CLevelParserParam::CLevelParserParam(glm::vec2 value) { - m_array.push_back(MakeUnique(value.x)); - m_array.push_back(MakeUnique(value.y)); + m_array.push_back(std::make_unique(value.x)); + m_array.push_back(std::make_unique(value.y)); LoadArray(); } CLevelParserParam::CLevelParserParam(glm::vec3 value) { - m_array.push_back(MakeUnique(value.x)); + m_array.push_back(std::make_unique(value.x)); if(value.y != 0.0f) - m_array.push_back(MakeUnique(value.y)); - m_array.push_back(MakeUnique(value.z)); + m_array.push_back(std::make_unique(value.y)); + m_array.push_back(std::make_unique(value.z)); LoadArray(); } @@ -1116,7 +1115,7 @@ void CLevelParserParam::ParseArray() { boost::algorithm::trim(value); if (value.empty()) continue; - auto param = MakeUnique(m_name + "[" + boost::lexical_cast(i) + "]", value); + auto param = std::make_unique(m_name + "[" + boost::lexical_cast(i) + "]", value); param->SetLine(m_line); m_array.push_back(std::move(param)); i++; diff --git a/src/level/player_profile.cpp b/src/level/player_profile.cpp index a88d052f..00c41898 100644 --- a/src/level/player_profile.cpp +++ b/src/level/player_profile.cpp @@ -21,7 +21,6 @@ #include "common/config_file.h" #include "common/logger.h" -#include "common/make_unique.h" #include "common/restext.h" #include "common/resources/inputstream.h" @@ -436,15 +435,15 @@ void CPlayerProfile::SaveApperance() CLevelParser apperanceParser(GetSaveFile("face.gam")); CLevelParserLineUPtr line; - line = MakeUnique("Head"); - line->AddParam("face", MakeUnique(m_apperance.face)); - line->AddParam("glasses", MakeUnique(m_apperance.glasses)); - line->AddParam("hair", MakeUnique(m_apperance.colorHair)); + line = std::make_unique("Head"); + line->AddParam("face", std::make_unique(m_apperance.face)); + line->AddParam("glasses", std::make_unique(m_apperance.glasses)); + line->AddParam("hair", std::make_unique(m_apperance.colorHair)); apperanceParser.AddLine(std::move(line)); - line = MakeUnique("Body"); - line->AddParam("combi", MakeUnique(m_apperance.colorCombi)); - line->AddParam("band", MakeUnique(m_apperance.colorBand)); + line = std::make_unique("Body"); + line->AddParam("combi", std::make_unique(m_apperance.colorCombi)); + line->AddParam("band", std::make_unique(m_apperance.colorBand)); apperanceParser.AddLine(std::move(line)); apperanceParser.Save(); diff --git a/src/level/robotmain.cpp b/src/level/robotmain.cpp index 83393008..2ae7956b 100644 --- a/src/level/robotmain.cpp +++ b/src/level/robotmain.cpp @@ -28,7 +28,6 @@ #include "common/config_file.h" #include "common/event.h" #include "common/logger.h" -#include "common/make_unique.h" #include "common/restext.h" #include "common/settings.h" #include "common/stringutils.h" @@ -152,26 +151,26 @@ CRobotMain::CRobotMain() m_planet = m_engine->GetPlanet(); m_input = CInput::GetInstancePointer(); - m_modelManager = MakeUnique(); - m_settings = MakeUnique(); - m_pause = MakeUnique(); - m_interface = MakeUnique(); - m_terrain = MakeUnique(); - m_camera = MakeUnique(); - m_displayText = MakeUnique(); - m_movie = MakeUnique(); - m_ui = MakeUnique(); - m_short = MakeUnique(); - m_map = MakeUnique(); + m_modelManager = std::make_unique(); + m_settings = std::make_unique(); + m_pause = std::make_unique(); + m_interface = std::make_unique(); + m_terrain = std::make_unique(); + m_camera = std::make_unique(); + m_displayText = std::make_unique(); + m_movie = std::make_unique(); + m_ui = std::make_unique(); + m_short = std::make_unique(); + m_map = std::make_unique(); - m_objMan = MakeUnique( + m_objMan = std::make_unique( m_engine, m_terrain.get(), m_oldModelManager, m_modelManager.get(), m_particle); - m_debugMenu = MakeUnique(this, m_engine, m_objMan.get(), m_sound); + m_debugMenu = std::make_unique(this, m_engine, m_objMan.get(), m_sound); m_time = 0.0f; m_gameTime = 0.0f; @@ -1045,14 +1044,14 @@ bool CRobotMain::ProcessEvent(Event &event) if (obj != nullptr) { CLevelParserLine line("CreateObject"); - line.AddParam("type", MakeUnique(obj->GetType())); + line.AddParam("type", std::make_unique(obj->GetType())); glm::vec3 pos = obj->GetPosition()/g_unit; pos.y = 0.0f; - line.AddParam("pos", MakeUnique(pos)); + line.AddParam("pos", std::make_unique(pos)); float dir = Math::NormAngle(obj->GetRotationY()) / Math::PI; - line.AddParam("dir", MakeUnique(dir)); + line.AddParam("dir", std::make_unique(dir)); std::stringstream ss; ss << line; @@ -1608,7 +1607,7 @@ void CRobotMain::StartDisplayInfo(const std::string& filename, int index) bool soluce = m_ui->GetSceneSoluce(); - m_displayInfo = MakeUnique(); + m_displayInfo = std::make_unique(); m_displayInfo->StartDisplayInfo(filename, index, soluce); m_displayInfo->SetPosition(0); } @@ -2980,7 +2979,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (line->GetCommand() == "AudioChange" && !resetObject) { - auto audioChange = MakeUnique(); + auto audioChange = std::make_unique(); audioChange->Read(line.get()); m_ui->GetLoadingScreen()->SetProgress(0.15f, RT_LOADING_MUSIC, audioChange->music); m_sound->CacheMusic(audioChange->music); @@ -3638,7 +3637,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (line->GetCommand() == "EndMissionTake" && !resetObject) { - auto endTake = MakeUnique(); + auto endTake = std::make_unique(); endTake->Read(line.get()); if (endTake->immediat) m_endTakeImmediat = true; @@ -3677,7 +3676,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (line->GetParam("enable")->AsBool(false)) { // Create the scoreboard - m_scoreboard = MakeUnique(); + m_scoreboard = std::make_unique(); m_scoreboard->SetSortType(line->GetParam("sort")->AsSortType(CScoreboard::SortType::SORT_ID)); } continue; @@ -3687,7 +3686,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) { if (!m_scoreboard) throw CLevelParserException("ScoreboardKillRule encountered but scoreboard is not enabled"); - auto rule = MakeUnique(); + auto rule = std::make_unique(); rule->Read(line.get()); m_scoreboard->AddKillRule(std::move(rule)); continue; @@ -3696,7 +3695,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) { if (!m_scoreboard) throw CLevelParserException("ScoreboardObjectRule encountered but scoreboard is not enabled"); - auto rule = MakeUnique(); + auto rule = std::make_unique(); rule->Read(line.get()); m_scoreboard->AddObjectRule(std::move(rule)); continue; @@ -3705,7 +3704,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) { if (!m_scoreboard) throw CLevelParserException("ScoreboardEndTakeRule encountered but scoreboard is not enabled"); - auto rule = MakeUnique(); + auto rule = std::make_unique(); rule->Read(line.get()); m_scoreboard->AddEndTakeRule(std::move(rule)); continue; @@ -4619,29 +4618,29 @@ bool CRobotMain::IOIsBusy() //! Writes an object into the backup file void CRobotMain::IOWriteObject(CLevelParserLine* line, CObject* obj, const std::string& programDir, int objRank) { - line->AddParam("type", MakeUnique(obj->GetType())); - line->AddParam("id", MakeUnique(obj->GetID())); - line->AddParam("pos", MakeUnique(obj->GetPosition()/g_unit)); - line->AddParam("angle", MakeUnique(obj->GetRotation() * Math::RAD_TO_DEG)); - line->AddParam("zoom", MakeUnique(obj->GetScale())); + line->AddParam("type", std::make_unique(obj->GetType())); + line->AddParam("id", std::make_unique(obj->GetID())); + line->AddParam("pos", std::make_unique(obj->GetPosition()/g_unit)); + line->AddParam("angle", std::make_unique(obj->GetRotation() * Math::RAD_TO_DEG)); + line->AddParam("zoom", std::make_unique(obj->GetScale())); if (obj->Implements(ObjectInterfaceType::Old)) { - line->AddParam("option", MakeUnique(obj->GetOption())); + line->AddParam("option", std::make_unique(obj->GetOption())); } if (obj->Implements(ObjectInterfaceType::Controllable)) { auto controllableObj = dynamic_cast(obj); - line->AddParam("trainer", MakeUnique(controllableObj->GetTrainer())); + line->AddParam("trainer", std::make_unique(controllableObj->GetTrainer())); if (controllableObj->GetSelect()) - line->AddParam("select", MakeUnique(true)); + line->AddParam("select", std::make_unique(true)); } obj->Write(line); if (obj->GetType() == OBJECT_BASE) - line->AddParam("run", MakeUnique(3)); // stops and open (PARAM_FIXSCENE) + line->AddParam("run", std::make_unique(3)); // stops and open (PARAM_FIXSCENE) if (obj->Implements(ObjectInterfaceType::ProgramStorage)) @@ -4665,7 +4664,7 @@ void CRobotMain::IOWriteObject(CLevelParserLine* line, CObject* obj, const std:: int run = dynamic_cast(*obj).GetProgramIndex(dynamic_cast(*obj).GetCurrentProgram()); if (run != -1) { - line->AddParam("run", MakeUnique(run+1)); + line->AddParam("run", std::make_unique(run+1)); } } } @@ -4686,48 +4685,48 @@ bool CRobotMain::IOWriteScene(std::string filename, std::string filecbot, std::s CLevelParser levelParser(filename); CLevelParserLineUPtr line; - line = MakeUnique("Title"); - line->AddParam("text", MakeUnique(std::string(info))); + line = std::make_unique("Title"); + line->AddParam("text", std::make_unique(std::string(info))); levelParser.AddLine(std::move(line)); //TODO: Do we need that? It's not used anyway - line = MakeUnique("Version"); - line->AddParam("maj", MakeUnique(0)); - line->AddParam("min", MakeUnique(1)); + line = std::make_unique("Version"); + line->AddParam("maj", std::make_unique(0)); + line->AddParam("min", std::make_unique(1)); levelParser.AddLine(std::move(line)); - line = MakeUnique("Created"); - line->AddParam("date", MakeUnique(static_cast(time(nullptr)))); + line = std::make_unique("Created"); + line->AddParam("date", std::make_unique(static_cast(time(nullptr)))); levelParser.AddLine(std::move(line)); - line = MakeUnique("Mission"); - line->AddParam("base", MakeUnique(GetLevelCategoryDir(m_levelCategory))); + line = std::make_unique("Mission"); + line->AddParam("base", std::make_unique(GetLevelCategoryDir(m_levelCategory))); if (m_levelCategory == LevelCategory::CustomLevels) - line->AddParam("dir", MakeUnique(GetCustomLevelDir())); + line->AddParam("dir", std::make_unique(GetCustomLevelDir())); else - line->AddParam("chap", MakeUnique(m_levelChap)); - line->AddParam("rank", MakeUnique(m_levelRank)); - line->AddParam("gametime", MakeUnique(GetGameTime())); + line->AddParam("chap", std::make_unique(m_levelChap)); + line->AddParam("rank", std::make_unique(m_levelRank)); + line->AddParam("gametime", std::make_unique(GetGameTime())); levelParser.AddLine(std::move(line)); - line = MakeUnique("Map"); - line->AddParam("zoom", MakeUnique(m_map->GetZoomMap())); + line = std::make_unique("Map"); + line->AddParam("zoom", std::make_unique(m_map->GetZoomMap())); levelParser.AddLine(std::move(line)); - line = MakeUnique("DoneResearch"); - line->AddParam("bits", MakeUnique(static_cast(m_researchDone[0]))); + line = std::make_unique("DoneResearch"); + line->AddParam("bits", std::make_unique(static_cast(m_researchDone[0]))); levelParser.AddLine(std::move(line)); float sleep, delay, magnetic, progress; if (m_lightning->GetStatus(sleep, delay, magnetic, progress)) { - line = MakeUnique("BlitzMode"); - line->AddParam("sleep", MakeUnique(sleep)); - line->AddParam("delay", MakeUnique(delay)); - line->AddParam("magnetic", MakeUnique(magnetic/g_unit)); - line->AddParam("progress", MakeUnique(progress)); + line = std::make_unique("BlitzMode"); + line->AddParam("sleep", std::make_unique(sleep)); + line->AddParam("delay", std::make_unique(delay)); + line->AddParam("magnetic", std::make_unique(magnetic/g_unit)); + line->AddParam("progress", std::make_unique(progress)); levelParser.AddLine(std::move(line)); } @@ -4747,19 +4746,19 @@ bool CRobotMain::IOWriteScene(std::string filename, std::string filecbot, std::s if (CObject *sub = slotted->GetSlotContainedObject(slot)) { if (slot == slotted->MapPseudoSlot(CSlottedObject::Pseudoslot::POWER)) - line = MakeUnique("CreatePower"); + line = std::make_unique("CreatePower"); else if (slot == slotted->MapPseudoSlot(CSlottedObject::Pseudoslot::CARRYING)) - line = MakeUnique("CreateFret"); + line = std::make_unique("CreateFret"); else - line = MakeUnique("CreateSlotObject"); - line->AddParam("slotNum", MakeUnique(slot)); + line = std::make_unique("CreateSlotObject"); + line->AddParam("slotNum", std::make_unique(slot)); IOWriteObject(line.get(), sub, dirname, objRank++); levelParser.AddLine(std::move(line)); } } } - line = MakeUnique("CreateObject"); + line = std::make_unique("CreateObject"); IOWriteObject(line.get(), obj, dirname, objRank++); levelParser.AddLine(std::move(line)); } @@ -4958,7 +4957,7 @@ CObject* CRobotMain::IOReadScene(std::string filename, std::string filecbot) // TODO: eww! assert(obj->Implements(ObjectInterfaceType::Old)); - auto task = MakeUnique(dynamic_cast(obj)); + auto task = std::make_unique(dynamic_cast(obj)); task->Start(TMO_AUTO, TMA_GRAB); // holds the object! } @@ -5062,7 +5061,7 @@ void CRobotMain::SelectPlayer(std::string playerName) { assert(!playerName.empty()); - m_playerProfile = MakeUnique(playerName); + m_playerProfile = std::make_unique(playerName); SetGlobalGamerName(playerName); } diff --git a/src/object/auto/auto.cpp b/src/object/auto/auto.cpp index e7d9352a..ebd41af6 100644 --- a/src/object/auto/auto.cpp +++ b/src/object/auto/auto.cpp @@ -23,7 +23,6 @@ #include "app/app.h" #include "common/event.h" -#include "common/make_unique.h" #include "graphics/engine/engine.h" @@ -408,11 +407,11 @@ void CAuto::SetMotor(bool bMotor) bool CAuto::Write(CLevelParserLine* line) { - line->AddParam("aType", MakeUnique(m_type)); - line->AddParam("aBusy", MakeUnique(m_bBusy)); - line->AddParam("aTime", MakeUnique(m_time)); - line->AddParam("aProgressTime", MakeUnique(m_progressTime)); - line->AddParam("aProgressTotal", MakeUnique(m_progressTotal)); + line->AddParam("aType", std::make_unique(m_type)); + line->AddParam("aBusy", std::make_unique(m_bBusy)); + line->AddParam("aTime", std::make_unique(m_time)); + line->AddParam("aProgressTime", std::make_unique(m_progressTime)); + line->AddParam("aProgressTotal", std::make_unique(m_progressTotal)); return false; } diff --git a/src/object/auto/autoconvert.cpp b/src/object/auto/autoconvert.cpp index 8b6651cf..ea2a8278 100644 --- a/src/object/auto/autoconvert.cpp +++ b/src/object/auto/autoconvert.cpp @@ -20,8 +20,6 @@ #include "object/auto/autoconvert.h" -#include "common/make_unique.h" - #include "graphics/engine/engine.h" #include "level/robotmain.h" @@ -369,11 +367,11 @@ bool CAutoConvert::Write(CLevelParserLine* line) if ( m_phase == ACP_STOP || m_phase == ACP_WAIT ) return false; - line->AddParam("aExist", MakeUnique(true)); + line->AddParam("aExist", std::make_unique(true)); CAuto::Write(line); - line->AddParam("aPhase", MakeUnique(static_cast(m_phase))); - line->AddParam("aProgress", MakeUnique(m_progress)); - line->AddParam("aSpeed", MakeUnique(m_speed)); + line->AddParam("aPhase", std::make_unique(static_cast(m_phase))); + line->AddParam("aProgress", std::make_unique(m_progress)); + line->AddParam("aSpeed", std::make_unique(m_speed)); return true; } diff --git a/src/object/auto/autoderrick.cpp b/src/object/auto/autoderrick.cpp index 90126caa..6bf97818 100644 --- a/src/object/auto/autoderrick.cpp +++ b/src/object/auto/autoderrick.cpp @@ -20,8 +20,6 @@ #include "object/auto/autoderrick.h" -#include "common/make_unique.h" - #include "graphics/engine/engine.h" #include "graphics/engine/terrain.h" @@ -435,11 +433,11 @@ bool CAutoDerrick::Write(CLevelParserLine* line) { if ( m_phase == ADP_WAIT ) return false; - line->AddParam("aExist", MakeUnique(true)); + line->AddParam("aExist", std::make_unique(true)); CAuto::Write(line); - line->AddParam("aPhase", MakeUnique(static_cast(m_phase))); - line->AddParam("aProgress", MakeUnique(m_progress)); - line->AddParam("aSpeed", MakeUnique(m_speed)); + line->AddParam("aPhase", std::make_unique(static_cast(m_phase))); + line->AddParam("aProgress", std::make_unique(m_progress)); + line->AddParam("aSpeed", std::make_unique(m_speed)); return true; } diff --git a/src/object/auto/autodestroyer.cpp b/src/object/auto/autodestroyer.cpp index f6147aa5..65a9e309 100644 --- a/src/object/auto/autodestroyer.cpp +++ b/src/object/auto/autodestroyer.cpp @@ -20,8 +20,6 @@ #include "object/auto/autodestroyer.h" -#include "common/make_unique.h" - #include "graphics/engine/engine.h" #include "graphics/engine/pyro_manager.h" @@ -317,11 +315,11 @@ bool CAutoDestroyer::Write(CLevelParserLine* line) { if ( m_phase == ADEP_WAIT ) return false; - line->AddParam("aExist", MakeUnique(true)); + line->AddParam("aExist", std::make_unique(true)); CAuto::Write(line); - line->AddParam("aPhase", MakeUnique(static_cast(m_phase))); - line->AddParam("aProgress", MakeUnique(m_progress)); - line->AddParam("aSpeed", MakeUnique(m_speed)); + line->AddParam("aPhase", std::make_unique(static_cast(m_phase))); + line->AddParam("aProgress", std::make_unique(m_progress)); + line->AddParam("aSpeed", std::make_unique(m_speed)); return true; } diff --git a/src/object/auto/autoegg.cpp b/src/object/auto/autoegg.cpp index d430bad4..fffca678 100644 --- a/src/object/auto/autoegg.cpp +++ b/src/object/auto/autoegg.cpp @@ -20,8 +20,6 @@ #include "object/auto/autoegg.h" -#include "common/make_unique.h" - #include "graphics/engine/engine.h" #include "graphics/engine/pyro_manager.h" @@ -320,14 +318,14 @@ bool CAutoEgg::Write(CLevelParserLine* line) { if ( m_phase == AEP_NULL ) return false; - line->AddParam("aExist", MakeUnique(true)); + line->AddParam("aExist", std::make_unique(true)); CAuto::Write(line); - line->AddParam("aPhase", MakeUnique(static_cast(m_phase))); - line->AddParam("aProgress", MakeUnique(m_progress)); - line->AddParam("aSpeed", MakeUnique(m_speed)); - line->AddParam("aParamType", MakeUnique(m_type)); - line->AddParam("aParamValue1", MakeUnique(m_value)); - line->AddParam("aParamString", MakeUnique(m_alienProgramName)); + line->AddParam("aPhase", std::make_unique(static_cast(m_phase))); + line->AddParam("aProgress", std::make_unique(m_progress)); + line->AddParam("aSpeed", std::make_unique(m_speed)); + line->AddParam("aParamType", std::make_unique(m_type)); + line->AddParam("aParamValue1", std::make_unique(m_value)); + line->AddParam("aParamString", std::make_unique(m_alienProgramName)); return true; } diff --git a/src/object/auto/autofactory.cpp b/src/object/auto/autofactory.cpp index dede332a..10ca5623 100644 --- a/src/object/auto/autofactory.cpp +++ b/src/object/auto/autofactory.cpp @@ -20,8 +20,6 @@ #include "object/auto/autofactory.h" -#include "common/make_unique.h" - #include "graphics/engine/engine.h" #include "level/robotmain.h" @@ -534,11 +532,11 @@ bool CAutoFactory::Write(CLevelParserLine* line) { if ( m_phase == AFP_WAIT ) return false; - line->AddParam("aExist", MakeUnique(true)); + line->AddParam("aExist", std::make_unique(true)); CAuto::Write(line); - line->AddParam("aPhase", MakeUnique(static_cast(m_phase))); - line->AddParam("aProgress", MakeUnique(m_progress)); - line->AddParam("aSpeed", MakeUnique(m_speed)); + line->AddParam("aPhase", std::make_unique(static_cast(m_phase))); + line->AddParam("aProgress", std::make_unique(m_progress)); + line->AddParam("aSpeed", std::make_unique(m_speed)); return true; } diff --git a/src/object/auto/autolabo.cpp b/src/object/auto/autolabo.cpp index 43837cd0..4a56043f 100644 --- a/src/object/auto/autolabo.cpp +++ b/src/object/auto/autolabo.cpp @@ -20,8 +20,6 @@ #include "object/auto/autolabo.h" -#include "common/make_unique.h" - #include "graphics/engine/engine.h" #include "level/robotmain.h" @@ -584,12 +582,12 @@ bool CAutoLabo::Write(CLevelParserLine* line) { if ( m_phase == ALAP_WAIT ) return false; - line->AddParam("aExist", MakeUnique(true)); + line->AddParam("aExist", std::make_unique(true)); CAuto::Write(line); - line->AddParam("aPhase", MakeUnique(static_cast(m_phase))); - line->AddParam("aProgress", MakeUnique(m_progress)); - line->AddParam("aSpeed", MakeUnique(m_speed)); - line->AddParam("aResearch", MakeUnique(static_cast(m_research))); + line->AddParam("aPhase", std::make_unique(static_cast(m_phase))); + line->AddParam("aProgress", std::make_unique(m_progress)); + line->AddParam("aSpeed", std::make_unique(m_speed)); + line->AddParam("aResearch", std::make_unique(static_cast(m_research))); return true; } diff --git a/src/object/auto/automush.cpp b/src/object/auto/automush.cpp index 74e1bac8..a70a7fd4 100644 --- a/src/object/auto/automush.cpp +++ b/src/object/auto/automush.cpp @@ -20,8 +20,6 @@ #include "object/auto/automush.h" -#include "common/make_unique.h" - #include "graphics/engine/engine.h" #include "level/parser/parserline.h" @@ -308,11 +306,11 @@ bool CAutoMush::Write(CLevelParserLine* line) { if ( m_phase == AMP_WAIT ) return false; - line->AddParam("aExist", MakeUnique(true)); + line->AddParam("aExist", std::make_unique(true)); CAuto::Write(line); - line->AddParam("aPhase", MakeUnique(static_cast(m_phase))); - line->AddParam("aProgress", MakeUnique(m_progress)); - line->AddParam("aSpeed", MakeUnique(m_speed)); + line->AddParam("aPhase", std::make_unique(static_cast(m_phase))); + line->AddParam("aProgress", std::make_unique(m_progress)); + line->AddParam("aSpeed", std::make_unique(m_speed)); return true; } diff --git a/src/object/auto/autonest.cpp b/src/object/auto/autonest.cpp index 1a3386e6..8747d3ba 100644 --- a/src/object/auto/autonest.cpp +++ b/src/object/auto/autonest.cpp @@ -20,8 +20,6 @@ #include "object/auto/autonest.h" -#include "common/make_unique.h" - #include "graphics/engine/engine.h" #include "graphics/engine/terrain.h" @@ -213,11 +211,11 @@ bool CAutoNest::Write(CLevelParserLine* line) { if ( m_phase == ANP_WAIT ) return false; - line->AddParam("aExist", MakeUnique(true)); + line->AddParam("aExist", std::make_unique(true)); CAuto::Write(line); - line->AddParam("aPhase", MakeUnique(static_cast(m_phase))); - line->AddParam("aProgress", MakeUnique(m_progress)); - line->AddParam("aSpeed", MakeUnique(m_speed)); + line->AddParam("aPhase", std::make_unique(static_cast(m_phase))); + line->AddParam("aProgress", std::make_unique(m_progress)); + line->AddParam("aSpeed", std::make_unique(m_speed)); return true; } diff --git a/src/object/auto/autonuclearplant.cpp b/src/object/auto/autonuclearplant.cpp index 6c3a2164..271f062b 100644 --- a/src/object/auto/autonuclearplant.cpp +++ b/src/object/auto/autonuclearplant.cpp @@ -20,8 +20,6 @@ #include "object/auto/autonuclearplant.h" -#include "common/make_unique.h" - #include "graphics/engine/engine.h" #include "level/robotmain.h" @@ -439,11 +437,11 @@ bool CAutoNuclearPlant::Write(CLevelParserLine* line) if ( m_phase == ANUP_STOP || m_phase == ANUP_WAIT ) return false; - line->AddParam("aExist", MakeUnique(true)); + line->AddParam("aExist", std::make_unique(true)); CAuto::Write(line); - line->AddParam("aPhase", MakeUnique(static_cast(m_phase))); - line->AddParam("aProgress", MakeUnique(m_progress)); - line->AddParam("aSpeed", MakeUnique(m_speed)); + line->AddParam("aPhase", std::make_unique(static_cast(m_phase))); + line->AddParam("aProgress", std::make_unique(m_progress)); + line->AddParam("aSpeed", std::make_unique(m_speed)); return true; } diff --git a/src/object/auto/autopowercaptor.cpp b/src/object/auto/autopowercaptor.cpp index ea144cf2..0cb16170 100644 --- a/src/object/auto/autopowercaptor.cpp +++ b/src/object/auto/autopowercaptor.cpp @@ -20,8 +20,6 @@ #include "object/auto/autopowercaptor.h" -#include "common/make_unique.h" - #include "graphics/engine/engine.h" #include "level/parser/parserline.h" @@ -295,11 +293,11 @@ bool CAutoPowerCaptor::Write(CLevelParserLine* line) { if ( m_phase == APAP_WAIT ) return false; - line->AddParam("aExist", MakeUnique(true)); + line->AddParam("aExist", std::make_unique(true)); CAuto::Write(line); - line->AddParam("aPhase", MakeUnique(static_cast(m_phase))); - line->AddParam("aProgress", MakeUnique(m_progress)); - line->AddParam("aSpeed", MakeUnique(m_speed)); + line->AddParam("aPhase", std::make_unique(static_cast(m_phase))); + line->AddParam("aProgress", std::make_unique(m_progress)); + line->AddParam("aSpeed", std::make_unique(m_speed)); return true; } diff --git a/src/object/auto/autopowerplant.cpp b/src/object/auto/autopowerplant.cpp index 70311968..f34ced1a 100644 --- a/src/object/auto/autopowerplant.cpp +++ b/src/object/auto/autopowerplant.cpp @@ -20,8 +20,6 @@ #include "object/auto/autopowerplant.h" -#include "common/make_unique.h" - #include "graphics/engine/engine.h" #include "graphics/engine/terrain.h" @@ -592,11 +590,11 @@ bool CAutoPowerPlant::Write(CLevelParserLine* line) if ( m_phase == AENP_STOP || m_phase == AENP_WAIT ) return false; - line->AddParam("aExist", MakeUnique(true)); + line->AddParam("aExist", std::make_unique(true)); CAuto::Write(line); - line->AddParam("aPhase", MakeUnique(static_cast(m_phase))); - line->AddParam("aProgress", MakeUnique(m_progress)); - line->AddParam("aSpeed", MakeUnique(m_speed)); + line->AddParam("aPhase", std::make_unique(static_cast(m_phase))); + line->AddParam("aProgress", std::make_unique(m_progress)); + line->AddParam("aSpeed", std::make_unique(m_speed)); return true; } diff --git a/src/object/auto/autorepair.cpp b/src/object/auto/autorepair.cpp index 93d2276a..da89b62f 100644 --- a/src/object/auto/autorepair.cpp +++ b/src/object/auto/autorepair.cpp @@ -20,8 +20,6 @@ #include "object/auto/autorepair.h" -#include "common/make_unique.h" - #include "graphics/engine/engine.h" #include "level/parser/parserline.h" @@ -279,11 +277,11 @@ bool CAutoRepair::Write(CLevelParserLine* line) { if ( m_phase == ARP_WAIT ) return false; - line->AddParam("aExist", MakeUnique(true)); + line->AddParam("aExist", std::make_unique(true)); CAuto::Write(line); - line->AddParam("aPhase", MakeUnique(static_cast(m_phase))); - line->AddParam("aProgress", MakeUnique(m_progress)); - line->AddParam("aSpeed", MakeUnique(m_speed)); + line->AddParam("aPhase", std::make_unique(static_cast(m_phase))); + line->AddParam("aProgress", std::make_unique(m_progress)); + line->AddParam("aSpeed", std::make_unique(m_speed)); return true; } diff --git a/src/object/auto/autoresearch.cpp b/src/object/auto/autoresearch.cpp index 996f5808..3fd5b83f 100644 --- a/src/object/auto/autoresearch.cpp +++ b/src/object/auto/autoresearch.cpp @@ -21,7 +21,6 @@ #include "object/auto/autoresearch.h" #include "common/global.h" -#include "common/make_unique.h" #include "graphics/engine/engine.h" @@ -569,12 +568,12 @@ bool CAutoResearch::Write(CLevelParserLine* line) { if ( m_phase == ALP_WAIT ) return false; - line->AddParam("aExist", MakeUnique(true)); + line->AddParam("aExist", std::make_unique(true)); CAuto::Write(line); - line->AddParam("aPhase", MakeUnique(static_cast(m_phase))); - line->AddParam("aProgress", MakeUnique(m_progress)); - line->AddParam("aSpeed", MakeUnique(m_speed)); - line->AddParam("aResearch", MakeUnique(static_cast(m_research))); + line->AddParam("aPhase", std::make_unique(static_cast(m_phase))); + line->AddParam("aProgress", std::make_unique(m_progress)); + line->AddParam("aSpeed", std::make_unique(m_speed)); + line->AddParam("aResearch", std::make_unique(static_cast(m_research))); return true; } diff --git a/src/object/auto/autotower.cpp b/src/object/auto/autotower.cpp index c3511266..aa49340d 100644 --- a/src/object/auto/autotower.cpp +++ b/src/object/auto/autotower.cpp @@ -20,8 +20,6 @@ #include "object/auto/autotower.h" -#include "common/make_unique.h" - #include "graphics/engine/engine.h" #include "level/robotmain.h" @@ -467,16 +465,16 @@ bool CAutoTower::Write(CLevelParserLine* line) { if ( m_phase == ATP_WAIT ) return false; - line->AddParam("aExist", MakeUnique(true)); + line->AddParam("aExist", std::make_unique(true)); CAuto::Write(line); - line->AddParam("aPhase", MakeUnique(static_cast(m_phase))); - line->AddParam("aProgress", MakeUnique(m_progress)); - line->AddParam("aSpeed", MakeUnique(m_speed)); - line->AddParam("aTargetPos", MakeUnique(m_targetPos)); - line->AddParam("aAngleYactual", MakeUnique(m_angleYactual)); - line->AddParam("aAngleZactual", MakeUnique(m_angleZactual)); - line->AddParam("aAngleYfinal", MakeUnique(m_angleYfinal)); - line->AddParam("aAngleZfinal", MakeUnique(m_angleZfinal)); + line->AddParam("aPhase", std::make_unique(static_cast(m_phase))); + line->AddParam("aProgress", std::make_unique(m_progress)); + line->AddParam("aSpeed", std::make_unique(m_speed)); + line->AddParam("aTargetPos", std::make_unique(m_targetPos)); + line->AddParam("aAngleYactual", std::make_unique(m_angleYactual)); + line->AddParam("aAngleZactual", std::make_unique(m_angleZactual)); + line->AddParam("aAngleYfinal", std::make_unique(m_angleYfinal)); + line->AddParam("aAngleZfinal", std::make_unique(m_angleZfinal)); return true; } diff --git a/src/object/auto/autovault.cpp b/src/object/auto/autovault.cpp index 3d27a5b6..72625cd7 100644 --- a/src/object/auto/autovault.cpp +++ b/src/object/auto/autovault.cpp @@ -20,8 +20,6 @@ #include "object/auto/autovault.h" -#include "common/make_unique.h" - #include "graphics/engine/engine.h" #include "level/robotmain.h" @@ -359,11 +357,11 @@ bool CAutoVault::Write(CLevelParserLine* line) { if ( m_phase == ASAP_WAIT ) return false; - line->AddParam("aExist", MakeUnique(true)); + line->AddParam("aExist", std::make_unique(true)); CAuto::Write(line); - line->AddParam("aPhase", MakeUnique(static_cast(m_phase))); - line->AddParam("aProgress", MakeUnique(m_progress)); - line->AddParam("aSpeed", MakeUnique(m_speed)); + line->AddParam("aPhase", std::make_unique(static_cast(m_phase))); + line->AddParam("aProgress", std::make_unique(m_progress)); + line->AddParam("aSpeed", std::make_unique(m_speed)); return true; } diff --git a/src/object/implementation/program_storage_impl.cpp b/src/object/implementation/program_storage_impl.cpp index 51906721..f7e0e123 100644 --- a/src/object/implementation/program_storage_impl.cpp +++ b/src/object/implementation/program_storage_impl.cpp @@ -101,8 +101,8 @@ bool CProgramStorageObjectImpl::GetActiveVirus() Program* CProgramStorageObjectImpl::AddProgram() { assert(m_object->Implements(ObjectInterfaceType::Old)); //TODO - auto program = MakeUnique(); - program->script = MakeUnique(dynamic_cast(this)); + auto program = std::make_unique(); + program->script = std::make_unique(dynamic_cast(this)); Program* prog = program.get(); AddProgram(std::move(program)); @@ -130,7 +130,7 @@ Program* CProgramStorageObjectImpl::CloneProgram(Program* program) Program* newprog = AddProgram(); // TODO: Is there any reason CScript doesn't have a function to get the program code directly? - auto edit = MakeUnique(); + auto edit = std::make_unique(); program->script->PutScript(edit.get(), ""); newprog->script->GetScript(edit.get()); @@ -314,15 +314,15 @@ void CProgramStorageObjectImpl::LoadAllProgramsForLevel(CLevelParserLine* levelS void CProgramStorageObjectImpl::SaveAllProgramsForSavedScene(CLevelParserLine* levelSourceLine, const std::string& levelSource) { - levelSourceLine->AddParam("programStorageIndex", MakeUnique(m_programStorageIndex)); + levelSourceLine->AddParam("programStorageIndex", std::make_unique(m_programStorageIndex)); for (unsigned int i = 0; i < m_program.size(); i++) { if (!m_program[i]->filename.empty() && m_program[i]->readOnly) { - levelSourceLine->AddParam("script" + StrUtils::ToString(i+1), MakeUnique(m_program[i]->filename)); - levelSourceLine->AddParam("scriptReadOnly" + StrUtils::ToString(i+1), MakeUnique(m_program[i]->readOnly)); - levelSourceLine->AddParam("scriptRunnable" + StrUtils::ToString(i+1), MakeUnique(m_program[i]->runnable)); + levelSourceLine->AddParam("script" + StrUtils::ToString(i+1), std::make_unique(m_program[i]->filename)); + levelSourceLine->AddParam("scriptReadOnly" + StrUtils::ToString(i+1), std::make_unique(m_program[i]->readOnly)); + levelSourceLine->AddParam("scriptRunnable" + StrUtils::ToString(i+1), std::make_unique(m_program[i]->runnable)); } } @@ -337,8 +337,8 @@ void CProgramStorageObjectImpl::SaveAllProgramsForSavedScene(CLevelParserLine* l GetLogger()->Trace("Saving program '%s' to saved scene\n", filename.c_str()); WriteProgram(m_program[i].get(), filename); - levelSourceLine->AddParam("scriptReadOnly" + StrUtils::ToString(i+1), MakeUnique(m_program[i]->readOnly)); - levelSourceLine->AddParam("scriptRunnable" + StrUtils::ToString(i+1), MakeUnique(m_program[i]->runnable)); + levelSourceLine->AddParam("scriptReadOnly" + StrUtils::ToString(i+1), std::make_unique(m_program[i]->readOnly)); + levelSourceLine->AddParam("scriptRunnable" + StrUtils::ToString(i+1), std::make_unique(m_program[i]->runnable)); } boost::regex regex(StrUtils::Format("prog%.3d([0-9]{3})\\.txt", m_programStorageIndex)); diff --git a/src/object/implementation/programmable_impl.cpp b/src/object/implementation/programmable_impl.cpp index b1dfa206..8e3a1a8b 100644 --- a/src/object/implementation/programmable_impl.cpp +++ b/src/object/implementation/programmable_impl.cpp @@ -251,7 +251,7 @@ void CProgrammableObjectImpl::TraceRecordStart() m_traceColor = TraceColor::Default; } - m_traceRecordBuffer = MakeUniqueArray(MAXTRACERECORD); + m_traceRecordBuffer = std::make_unique(MAXTRACERECORD); m_traceRecordIndex = 0; } diff --git a/src/object/implementation/task_executor_impl.cpp b/src/object/implementation/task_executor_impl.cpp index 892f2a1f..6c12de2d 100644 --- a/src/object/implementation/task_executor_impl.cpp +++ b/src/object/implementation/task_executor_impl.cpp @@ -142,7 +142,7 @@ Error CTaskExecutorObjectImpl::StartForegroundTask(Args&&... args) StopForegroundTask(); assert(m_object->Implements(ObjectInterfaceType::Old)); //TODO - std::unique_ptr task = MakeUnique(dynamic_cast(m_object)); + std::unique_ptr task = std::make_unique(dynamic_cast(m_object)); Error err = task->Start(std::forward(args)...); if (err == ERR_OK) m_foregroundTask = std::move(task); @@ -168,7 +168,7 @@ Error CTaskExecutorObjectImpl::StartBackgroundTask(Args&&... args) m_backgroundTask.reset(); // In case the old task was of a different type assert(m_object->Implements(ObjectInterfaceType::Old)); //TODO - std::unique_ptr newTask = MakeUnique(dynamic_cast(m_object)); + std::unique_ptr newTask = std::make_unique(dynamic_cast(m_object)); err = newTask->Start(std::forward(args)...); if (err == ERR_OK) m_backgroundTask = std::move(newTask); diff --git a/src/object/motion/motion.cpp b/src/object/motion/motion.cpp index c5bc22a8..e9411d96 100644 --- a/src/object/motion/motion.cpp +++ b/src/object/motion/motion.cpp @@ -22,8 +22,6 @@ #include "app/app.h" -#include "common/make_unique.h" - #include "graphics/engine/engine.h" #include "level/robotmain.h" @@ -164,9 +162,9 @@ bool CMotion::Write(CLevelParserLine* line) { if ( m_actionType == -1 ) return false; - line->AddParam("mType", MakeUnique(m_actionType)); - line->AddParam("mTime", MakeUnique(m_actionTime)); - line->AddParam("mProgress", MakeUnique(m_progress)); + line->AddParam("mType", std::make_unique(m_actionType)); + line->AddParam("mTime", std::make_unique(m_actionTime)); + line->AddParam("mProgress", std::make_unique(m_progress)); return false; } diff --git a/src/object/object_factory.cpp b/src/object/object_factory.cpp index ba690cf7..c061469c 100644 --- a/src/object/object_factory.cpp +++ b/src/object/object_factory.cpp @@ -19,8 +19,6 @@ #include "object/object_factory.h" -#include "common/make_unique.h" - #include "graphics/engine/engine.h" #include "graphics/engine/lightning.h" #include "graphics/engine/oldmodelmanager.h" @@ -335,7 +333,7 @@ CObjectUPtr CObjectFactory::CreateResource(const ObjectCreateParams& params) ObjectType type = params.type; float power = params.power; - auto obj = MakeUnique(params.id); + auto obj = std::make_unique(params.id); obj->SetType(type); obj->SetTeam(params.team); @@ -450,7 +448,7 @@ CObjectUPtr CObjectFactory::CreateFlag(const ObjectCreateParams& params) float angle = params.angle; ObjectType type = params.type; - auto obj = MakeUnique(params.id); + auto obj = std::make_unique(params.id); obj->SetType(type); obj->SetTeam(params.team); @@ -512,7 +510,7 @@ CObjectUPtr CObjectFactory::CreateBarrier(const ObjectCreateParams& params) float height = params.height; ObjectType type = params.type; - auto obj = MakeUnique(params.id); + auto obj = std::make_unique(params.id); obj->SetType(type); obj->SetTeam(params.team); @@ -652,7 +650,7 @@ CObjectUPtr CObjectFactory::CreatePlant(const ObjectCreateParams& params) float height = params.height; ObjectType type = params.type; - auto obj = MakeUnique(params.id); + auto obj = std::make_unique(params.id); obj->SetType(type); obj->SetTeam(params.team); @@ -894,7 +892,7 @@ CObjectUPtr CObjectFactory::CreateMushroom(const ObjectCreateParams& params) float height = params.height; ObjectType type = params.type; - auto obj = MakeUnique(params.id); + auto obj = std::make_unique(params.id); obj->SetType(type); obj->SetTeam(params.team); @@ -954,7 +952,7 @@ CObjectUPtr CObjectFactory::CreateTeen(const ObjectCreateParams& params) ObjectType type = params.type; int option = params.option; - COldObjectUPtr obj = MakeUnique(params.id); + COldObjectUPtr obj = std::make_unique(params.id); obj->SetType(type); obj->SetOption(option); @@ -1741,7 +1739,7 @@ CObjectUPtr CObjectFactory::CreateQuartz(const ObjectCreateParams& params) float height = params.height; ObjectType type = params.type; - auto obj = MakeUnique(params.id); + auto obj = std::make_unique(params.id); obj->SetType(type); obj->SetTeam(params.team); @@ -1848,7 +1846,7 @@ CObjectUPtr CObjectFactory::CreateRoot(const ObjectCreateParams& params) float height = params.height; ObjectType type = params.type; - auto obj = MakeUnique(params.id); + auto obj = std::make_unique(params.id); obj->SetType(type); @@ -2015,7 +2013,7 @@ CObjectUPtr CObjectFactory::CreateHome(const ObjectCreateParams& params) float height = params.height; ObjectType type = params.type; - auto obj = MakeUnique(params.id); + auto obj = std::make_unique(params.id); obj->SetType(type); obj->SetTeam(params.team); @@ -2056,7 +2054,7 @@ CObjectUPtr CObjectFactory::CreateRuin(const ObjectCreateParams& params) float height = params.height; ObjectType type = params.type; - auto obj = MakeUnique(params.id); + auto obj = std::make_unique(params.id); obj->SetType(type); obj->SetTeam(params.team); @@ -2472,7 +2470,7 @@ CObjectUPtr CObjectFactory::CreateApollo(const ObjectCreateParams& params) float angle = params.angle; ObjectType type = params.type; - auto obj = MakeUnique(params.id); + auto obj = std::make_unique(params.id); obj->SetType(type); obj->SetTeam(params.team); @@ -2588,15 +2586,15 @@ void CObjectFactory::AddObjectAuto(COldObject* obj) if ( type == OBJECT_EGG ) { - objAuto = MakeUnique(obj); + objAuto = std::make_unique(obj); } if ( type == OBJECT_ROOT5 ) { - objAuto = MakeUnique(obj); + objAuto = std::make_unique(obj); } if ( type == OBJECT_MUSHROOM2 ) { - objAuto = MakeUnique(obj); + objAuto = std::make_unique(obj); } if ( type == OBJECT_FLAGb || type == OBJECT_FLAGr || @@ -2604,13 +2602,13 @@ void CObjectFactory::AddObjectAuto(COldObject* obj) type == OBJECT_FLAGy || type == OBJECT_FLAGv ) { - objAuto = MakeUnique(obj); + objAuto = std::make_unique(obj); } if ( type == OBJECT_TEEN36 || // trunk? type == OBJECT_TEEN37 || // boat? type == OBJECT_TEEN38 ) // fan? { - objAuto = MakeUnique(obj); + objAuto = std::make_unique(obj); } if (objAuto != nullptr) diff --git a/src/object/object_manager.cpp b/src/object/object_manager.cpp index 09d73878..972a2392 100644 --- a/src/object/object_manager.cpp +++ b/src/object/object_manager.cpp @@ -20,7 +20,6 @@ #include "object/object_manager.h" #include "common/global.h" -#include "common/make_unique.h" #include "math/all.h" @@ -41,7 +40,7 @@ CObjectManager::CObjectManager(Gfx::CEngine* engine, Gfx::COldModelManager* oldModelManager, Gfx::CModelManager* modelManager, Gfx::CParticle* particle) - : m_objectFactory(MakeUnique(engine, + : m_objectFactory(std::make_unique(engine, terrain, oldModelManager, modelManager, diff --git a/src/object/old_object.cpp b/src/object/old_object.cpp index 79ec7bb5..a0fcb7c8 100644 --- a/src/object/old_object.cpp +++ b/src/object/old_object.cpp @@ -23,7 +23,6 @@ #include "app/app.h" #include "common/global.h" -#include "common/make_unique.h" #include "common/settings.h" #include "common/stringutils.h" @@ -1071,74 +1070,74 @@ void COldObject::Write(CLevelParserLine* line) { glm::vec3 pos; - line->AddParam("camera", MakeUnique(GetCameraType())); + line->AddParam("camera", std::make_unique(GetCameraType())); if ( GetCameraLock() ) - line->AddParam("cameraLock", MakeUnique(GetCameraLock())); + line->AddParam("cameraLock", std::make_unique(GetCameraLock())); if ( IsBulletWall() ) - line->AddParam("bulletWall", MakeUnique(IsBulletWall())); + line->AddParam("bulletWall", std::make_unique(IsBulletWall())); if ( GetEnergyLevel() != 0.0f ) - line->AddParam("energy", MakeUnique(GetEnergyLevel())); + line->AddParam("energy", std::make_unique(GetEnergyLevel())); if ( GetShield() != 1.0f ) - line->AddParam("shield", MakeUnique(GetShield())); + line->AddParam("shield", std::make_unique(GetShield())); if ( GetRange() != 1.0f ) - line->AddParam("range", MakeUnique(GetRange())); + line->AddParam("range", std::make_unique(GetRange())); if ( !GetSelectable() ) - line->AddParam("selectable", MakeUnique(GetSelectable())); + line->AddParam("selectable", std::make_unique(GetSelectable())); if ( !GetCollisions() ) - line->AddParam("clip", MakeUnique(GetCollisions())); + line->AddParam("clip", std::make_unique(GetCollisions())); if ( GetLock() ) - line->AddParam("lock", MakeUnique(GetLock())); + line->AddParam("lock", std::make_unique(GetLock())); if ( !GetActivity() ) - line->AddParam("activity", MakeUnique(GetActivity())); + line->AddParam("activity", std::make_unique(GetActivity())); if ( GetProxyActivate() ) { - line->AddParam("proxyActivate", MakeUnique(GetProxyActivate())); - line->AddParam("proxyDistance", MakeUnique(GetProxyDistance()/g_unit)); + line->AddParam("proxyActivate", std::make_unique(GetProxyActivate())); + line->AddParam("proxyDistance", std::make_unique(GetProxyDistance()/g_unit)); } if ( GetMagnifyDamage() != 1.0f ) - line->AddParam("magnifyDamage", MakeUnique(GetMagnifyDamage())); + line->AddParam("magnifyDamage", std::make_unique(GetMagnifyDamage())); if ( GetTeam() != 0 ) - line->AddParam("team", MakeUnique(GetTeam())); + line->AddParam("team", std::make_unique(GetTeam())); if ( GetGunGoalV() != 0.0f ) - line->AddParam("aimV", MakeUnique(GetGunGoalV())); + line->AddParam("aimV", std::make_unique(GetGunGoalV())); if ( GetGunGoalH() != 0.0f ) - line->AddParam("aimH", MakeUnique(GetGunGoalH())); + line->AddParam("aimH", std::make_unique(GetGunGoalH())); if ( GetAnimateOnReset() ) { - line->AddParam("reset", MakeUnique(GetAnimateOnReset())); + line->AddParam("reset", std::make_unique(GetAnimateOnReset())); } if ( m_bVirusMode ) - line->AddParam("virusMode", MakeUnique(m_bVirusMode)); + line->AddParam("virusMode", std::make_unique(m_bVirusMode)); if ( m_virusTime != 0.0f ) - line->AddParam("virusTime", MakeUnique(m_virusTime)); + line->AddParam("virusTime", std::make_unique(m_virusTime)); - line->AddParam("lifetime", MakeUnique(m_aTime)); + line->AddParam("lifetime", std::make_unique(m_aTime)); // Sets the parameters of the command line. CLevelParserParamVec cmdline; for(float value : GetCmdLine()) { - cmdline.push_back(MakeUnique(value)); + cmdline.push_back(std::make_unique(value)); } if (cmdline.size() > 0) - line->AddParam("cmdline", MakeUnique(std::move(cmdline))); + line->AddParam("cmdline", std::make_unique(std::move(cmdline))); if ( m_motion != nullptr ) { @@ -1147,7 +1146,7 @@ void COldObject::Write(CLevelParserLine* line) if ( Implements(ObjectInterfaceType::Programmable) ) { - line->AddParam("bVirusActive", MakeUnique(GetActiveVirus())); + line->AddParam("bVirusActive", std::make_unique(GetActiveVirus())); } if ( m_physics != nullptr ) @@ -2698,7 +2697,7 @@ bool COldObject::JostleObject(float force) { if ( m_auto != nullptr ) return false; - auto autoJostle = MakeUnique(this); + auto autoJostle = std::make_unique(this); autoJostle->Start(0, force); m_auto = std::move(autoJostle); } @@ -2789,7 +2788,7 @@ void COldObject::SetSelect(bool select, bool bDisplayError) { if ( m_objectInterface == nullptr ) { - m_objectInterface = MakeUnique(this); + m_objectInterface = std::make_unique(this); } m_objectInterface->CreateInterface(m_bSelect); } diff --git a/src/object/subclass/base_alien.cpp b/src/object/subclass/base_alien.cpp index 2a2faabf..741835c0 100644 --- a/src/object/subclass/base_alien.cpp +++ b/src/object/subclass/base_alien.cpp @@ -19,8 +19,6 @@ #include "object/subclass/base_alien.h" -#include "common/make_unique.h" - #include "level/parser/parserline.h" #include "level/parser/parserparam.h" @@ -48,32 +46,32 @@ std::unique_ptr CBaseAlien::Create( Gfx::COldModelManager* modelManager, Gfx::CEngine* engine) { - auto obj = MakeUnique(params.id, params.type); + auto obj = std::make_unique(params.id, params.type); obj->SetTeam(params.team); - std::unique_ptr physics = MakeUnique(obj.get()); + std::unique_ptr physics = std::make_unique(obj.get()); std::unique_ptr motion; if ( params.type == OBJECT_MOTHER ) { - motion = MakeUnique(obj.get()); + motion = std::make_unique(obj.get()); } if ( params.type == OBJECT_ANT ) { - motion = MakeUnique(obj.get()); + motion = std::make_unique(obj.get()); } if ( params.type == OBJECT_SPIDER ) { - motion = MakeUnique(obj.get()); + motion = std::make_unique(obj.get()); } if ( params.type == OBJECT_BEE ) { - motion = MakeUnique(obj.get()); + motion = std::make_unique(obj.get()); } if ( params.type == OBJECT_WORM ) { - motion = MakeUnique(obj.get()); + motion = std::make_unique(obj.get()); } assert(motion != nullptr); @@ -110,5 +108,5 @@ void CBaseAlien::Write(CLevelParserLine* line) COldObject::Write(line); if (GetFixed()) - line->AddParam("fixed", MakeUnique(GetFixed())); + line->AddParam("fixed", std::make_unique(GetFixed())); } diff --git a/src/object/subclass/base_building.cpp b/src/object/subclass/base_building.cpp index b37b295f..e6e12dde 100644 --- a/src/object/subclass/base_building.cpp +++ b/src/object/subclass/base_building.cpp @@ -19,8 +19,6 @@ #include "object/subclass/base_building.h" -#include "common/make_unique.h" - #include "graphics/engine/engine.h" #include "graphics/engine/oldmodelmanager.h" #include "graphics/engine/terrain.h" @@ -63,7 +61,7 @@ std::unique_ptr CBaseBuilding::Create( Gfx::COldModelManager* modelManager, Gfx::CEngine* engine) { - auto obj = MakeUnique(params.id, params.type); + auto obj = std::make_unique(params.id, params.type); obj->SetTrainer(params.trainer || obj->GetPlusTrainer()); obj->SetTeam(params.team); @@ -810,75 +808,75 @@ std::unique_ptr CBaseBuilding::Create( std::unique_ptr objAuto; if ( params.type == OBJECT_BASE ) { - objAuto = MakeUnique(obj.get()); + objAuto = std::make_unique(obj.get()); } if ( params.type == OBJECT_PORTICO ) { - objAuto = MakeUnique(obj.get()); + objAuto = std::make_unique(obj.get()); } if ( params.type == OBJECT_DERRICK ) { - objAuto = MakeUnique(obj.get()); + objAuto = std::make_unique(obj.get()); } if ( params.type == OBJECT_FACTORY ) { - objAuto = MakeUnique(obj.get()); + objAuto = std::make_unique(obj.get()); } if ( params.type == OBJECT_REPAIR ) { - objAuto = MakeUnique(obj.get()); + objAuto = std::make_unique(obj.get()); } if ( params.type == OBJECT_DESTROYER ) { - objAuto = MakeUnique(obj.get()); + objAuto = std::make_unique(obj.get()); } if ( params.type == OBJECT_STATION ) { - objAuto = MakeUnique(obj.get()); + objAuto = std::make_unique(obj.get()); } if ( params.type == OBJECT_CONVERT ) { - objAuto = MakeUnique(obj.get()); + objAuto = std::make_unique(obj.get()); } if ( params.type == OBJECT_TOWER ) { - objAuto = MakeUnique(obj.get()); + objAuto = std::make_unique(obj.get()); } if ( params.type == OBJECT_RESEARCH ) { - objAuto = MakeUnique(obj.get()); + objAuto = std::make_unique(obj.get()); } if ( params.type == OBJECT_RADAR ) { - objAuto = MakeUnique(obj.get()); + objAuto = std::make_unique(obj.get()); } if ( params.type == OBJECT_ENERGY ) { - objAuto = MakeUnique(obj.get()); + objAuto = std::make_unique(obj.get()); } if ( params.type == OBJECT_LABO ) { - objAuto = MakeUnique(obj.get()); + objAuto = std::make_unique(obj.get()); } if ( params.type == OBJECT_NUCLEAR ) { - objAuto = MakeUnique(obj.get()); + objAuto = std::make_unique(obj.get()); } if ( params.type == OBJECT_PARA ) { - objAuto = MakeUnique(obj.get()); + objAuto = std::make_unique(obj.get()); } if ( params.type == OBJECT_SAFE ) { - objAuto = MakeUnique(obj.get()); + objAuto = std::make_unique(obj.get()); } if ( params.type == OBJECT_HUSTON ) { - objAuto = MakeUnique(obj.get()); + objAuto = std::make_unique(obj.get()); } if ( params.type == OBJECT_NEST ) { - objAuto = MakeUnique(obj.get()); + objAuto = std::make_unique(obj.get()); } if (objAuto != nullptr) diff --git a/src/object/subclass/base_robot.cpp b/src/object/subclass/base_robot.cpp index 942e7ef5..1b118743 100644 --- a/src/object/subclass/base_robot.cpp +++ b/src/object/subclass/base_robot.cpp @@ -19,8 +19,6 @@ #include "object/subclass/base_robot.h" -#include "common/make_unique.h" - #include "graphics/engine/oldmodelmanager.h" #include "object/object_create_params.h" @@ -45,14 +43,14 @@ std::unique_ptr CBaseRobot::Create( Gfx::COldModelManager* modelManager, Gfx::CEngine* engine) { - auto obj = MakeUnique(params.id, params.type); + auto obj = std::make_unique(params.id, params.type); obj->SetOption(params.option); obj->SetTeam(params.team); if ( params.type == OBJECT_TOTO ) { - auto motion = MakeUnique(obj.get()); + auto motion = std::make_unique(obj.get()); motion->Create(params.pos, params.angle, params.type, 1.0f, modelManager); obj->SetMovable(std::move(motion), nullptr); return obj; @@ -70,21 +68,21 @@ std::unique_ptr CBaseRobot::Create( obj->SetToy(params.toy); - auto physics = MakeUnique(obj.get()); + auto physics = std::make_unique(obj.get()); std::unique_ptr motion; if ( params.type == OBJECT_HUMAN || params.type == OBJECT_TECH ) { - motion = MakeUnique(obj.get()); + motion = std::make_unique(obj.get()); } else if ( params.type == OBJECT_CONTROLLER ) { - motion = MakeUnique(obj.get()); + motion = std::make_unique(obj.get()); } else { - motion = MakeUnique(obj.get()); + motion = std::make_unique(obj.get()); } motion->SetPhysics(physics.get()); diff --git a/src/object/subclass/exchange_post.cpp b/src/object/subclass/exchange_post.cpp index 34075984..ab16865a 100644 --- a/src/object/subclass/exchange_post.cpp +++ b/src/object/subclass/exchange_post.cpp @@ -19,7 +19,6 @@ #include "object/subclass/exchange_post.h" -#include "common/make_unique.h" #include "common/regex_utils.h" #include "graphics/engine/engine.h" @@ -52,7 +51,7 @@ std::unique_ptr CExchangePost::Create( Gfx::COldModelManager* modelManager, Gfx::CEngine* engine) { - auto obj = MakeUnique(params.id); + auto obj = std::make_unique(params.id); obj->SetTeam(params.team); @@ -101,7 +100,7 @@ std::unique_ptr CExchangePost::Create( pos.y += params.height; obj->SetPosition(pos); // to display the shadows immediately - auto objAuto = MakeUnique(obj.get()); + auto objAuto = std::make_unique(obj.get()); objAuto->Init(); obj->SetAuto(std::move(objAuto)); @@ -205,7 +204,7 @@ void CExchangePost::Write(CLevelParserLine* line) { auto key = "info" + boost::lexical_cast(i); auto paramValue = info.name + "=" + boost::lexical_cast(info.value); - line->AddParam(key, MakeUnique(paramValue)); + line->AddParam(key, std::make_unique(paramValue)); } } } @@ -670,11 +669,11 @@ bool CAutoInfo::Write(CLevelParserLine* line) if (m_phase == Phase::Wait) return false; - line->AddParam("aExist", MakeUnique(true)); + line->AddParam("aExist", std::make_unique(true)); CAuto::Write(line); - line->AddParam("aPhase", MakeUnique(static_cast(m_phase))); - line->AddParam("aProgress", MakeUnique(m_progress)); - line->AddParam("aSpeed", MakeUnique(m_speed)); + line->AddParam("aPhase", std::make_unique(static_cast(m_phase))); + line->AddParam("aProgress", std::make_unique(m_progress)); + line->AddParam("aSpeed", std::make_unique(m_speed)); return true; } diff --git a/src/object/subclass/shielder.cpp b/src/object/subclass/shielder.cpp index e8c0224f..b98786a2 100644 --- a/src/object/subclass/shielder.cpp +++ b/src/object/subclass/shielder.cpp @@ -19,8 +19,6 @@ #include "object/subclass/shielder.h" -#include "common/make_unique.h" - #include "graphics/engine/oldmodelmanager.h" #include "level/parser/parserline.h" @@ -49,14 +47,14 @@ std::unique_ptr CShielder::Create( Gfx::CEngine* engine) { assert(params.type == OBJECT_MOBILErs); - auto obj = MakeUnique(params.id); + auto obj = std::make_unique(params.id); obj->SetTeam(params.team); obj->SetTrainer(params.trainer || obj->GetPlusTrainer()); obj->SetToy(params.toy); - auto physics = MakeUnique(obj.get()); - auto motion = MakeUnique(obj.get()); + auto physics = std::make_unique(obj.get()); + auto motion = std::make_unique(obj.get()); motion->SetPhysics(physics.get()); physics->SetMotion(motion.get()); @@ -109,5 +107,5 @@ void CShielder::Write(CLevelParserLine* line) { COldObject::Write(line); - line->AddParam("bShieldActive", MakeUnique(IsBackgroundTask())); + line->AddParam("bShieldActive", std::make_unique(IsBackgroundTask())); } diff --git a/src/object/subclass/static_object.cpp b/src/object/subclass/static_object.cpp index 3403e593..d886dd4f 100644 --- a/src/object/subclass/static_object.cpp +++ b/src/object/subclass/static_object.cpp @@ -19,8 +19,6 @@ #include "object/subclass/static_object.h" -#include "common/make_unique.h" - #include "graphics/engine/engine.h" #include "graphics/engine/terrain.h" @@ -141,7 +139,7 @@ CStaticObjectUPtr CStaticObject::Create(int id, if (model.GetMeshCount() != 1 || model.GetMesh("main") == nullptr) throw CObjectCreateException("Unexpected mesh configuration", type, modelFile); - return MakeUnique(id, type, modelFile, adjustedPosition, angleY, model, engine); + return std::make_unique(id, type, modelFile, adjustedPosition, angleY, model, engine); } catch (const Gfx::CModelIOException& e) { diff --git a/src/object/task/taskgoto.cpp b/src/object/task/taskgoto.cpp index 7bea2d94..e98ae42c 100644 --- a/src/object/task/taskgoto.cpp +++ b/src/object/task/taskgoto.cpp @@ -23,7 +23,6 @@ #include "common/event.h" #include "common/global.h" #include "common/image.h" -#include "common/make_unique.h" #include "graphics/engine/engine.h" #include "graphics/engine/terrain.h" @@ -120,7 +119,7 @@ bool CTaskGoto::EventProcess(const Event &event) { if (m_bmArray != nullptr) { - std::unique_ptr debugImage = MakeUnique(glm::ivec2(m_bmSize, m_bmSize)); + std::unique_ptr debugImage = std::make_unique(glm::ivec2(m_bmSize, m_bmSize)); debugImage->Fill(Gfx::IntColor(255, 255, 255, 255)); for (int x = 0; x < m_bmSize; x++) { @@ -2100,7 +2099,7 @@ bool CTaskGoto::BitmapOpen() BitmapClose(); m_bmSize = static_cast(3200.0f/BM_DIM_STEP); - m_bmArray = MakeUniqueArray(m_bmSize*m_bmSize/8*2); + m_bmArray = std::make_unique(m_bmSize * m_bmSize / 8 * 2); m_bmChanged = true; m_bmOffset = m_bmSize/2; diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp index bcfbbd0b..826f6672 100644 --- a/src/physics/physics.cpp +++ b/src/physics/physics.cpp @@ -24,7 +24,6 @@ #include "common/event.h" #include "common/global.h" -#include "common/make_unique.h" #include "graphics/engine/camera.h" #include "graphics/engine/engine.h" @@ -162,15 +161,15 @@ void CPhysics::SetMotion(CMotion* motion) bool CPhysics::Write(CLevelParserLine* line) { - line->AddParam("motor", MakeUnique(m_motorSpeed)); + line->AddParam("motor", std::make_unique(m_motorSpeed)); if ( m_object->Implements(ObjectInterfaceType::Flying) ) { if ( m_object->Implements(ObjectInterfaceType::JetFlying) ) { - line->AddParam("reactorRange", MakeUnique(m_object->GetReactorRange())); + line->AddParam("reactorRange", std::make_unique(m_object->GetReactorRange())); } - line->AddParam("land", MakeUnique(GetLand())); + line->AddParam("land", std::make_unique(GetLand())); } return true; diff --git a/src/script/script.cpp b/src/script/script.cpp index cb1861fb..131f9d19 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -105,7 +105,7 @@ void CScript::PutScript(Ui::CEdit* edit, const char* name) bool CScript::GetScript(Ui::CEdit* edit) { int len = edit->GetTextLength(); - m_script = MakeUniqueArray(len+2); + m_script = std::make_unique(len + 2); std::string tmp = edit->GetText(len+1); strncpy(m_script.get(), tmp.c_str(), len+1); @@ -237,7 +237,7 @@ bool CScript::Compile() if (m_botProg == nullptr) { - m_botProg = MakeUnique(m_object->GetBotVar()); + m_botProg = std::make_unique(m_object->GetBotVar()); } if ( m_botProg->Compile(m_script.get(), functionList, this) ) @@ -804,7 +804,7 @@ bool CScript::IntroduceVirus() int start = found[i+1]; i = found[i+0]; - auto newScript = MakeUniqueArray(m_len + strlen(names[i+1]) + 1); + auto newScript = std::make_unique(m_len + strlen(names[i + 1]) + 1); strcpy(newScript.get(), m_script.get()); m_script = std::move(newScript); diff --git a/src/script/scriptfunc.cpp b/src/script/scriptfunc.cpp index c0f0c380..e3483b49 100644 --- a/src/script/scriptfunc.cpp +++ b/src/script/scriptfunc.cpp @@ -25,7 +25,6 @@ #include "common/global.h" #include "common/logger.h" -#include "common/make_unique.h" #include "common/resources/inputstream.h" #include "common/resources/outputstream.h" @@ -3317,7 +3316,7 @@ public: { if (mode == CBotFileAccessHandler::OpenMode::Read) { - auto is = MakeUnique(filename); + auto is = std::make_unique(filename); if (is->is_open()) { m_file = std::move(is); @@ -3325,7 +3324,7 @@ public: } else if (mode == CBotFileAccessHandler::OpenMode::Write) { - auto os = MakeUnique(filename); + auto os = std::make_unique(filename); if (os->is_open()) { m_file = std::move(os); @@ -3333,7 +3332,7 @@ public: } else if (mode == CBotFileAccessHandler::OpenMode::Append) { - auto os = MakeUnique(filename, std::ios_base::app); + auto os = std::make_unique(filename, std::ios_base::app); if (os->is_open()) { m_file = std::move(os); @@ -3405,7 +3404,7 @@ class CBotFileAccessHandlerColobot : public CBotFileAccessHandler public: virtual std::unique_ptr OpenFile(const std::string& filename, OpenMode mode) override { - return MakeUnique(PrepareFilename(filename), mode); + return std::make_unique(PrepareFilename(filename), mode); } virtual bool DeleteFile(const std::string& filename) override @@ -3613,7 +3612,7 @@ void CScriptFunctions::Init() CBotProgram::AddFunction("research", rResearch, cResearch); CBotProgram::AddFunction("destroy", rDestroy, cOneObject); - SetFileAccessHandler(MakeUnique()); + SetFileAccessHandler(std::make_unique()); } diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index 99c0357a..94ce9f8c 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -20,8 +20,6 @@ #include "sound/oalsound/alsound.h" -#include "common/make_unique.h" - #include #include @@ -138,7 +136,7 @@ int CALSound::GetMusicVolume() bool CALSound::Cache(SoundType sound, const std::string &filename) { - auto buffer = MakeUnique(); + auto buffer = std::make_unique(); if (buffer->LoadFromFile(filename, sound)) { m_sounds[sound] = std::move(buffer); @@ -153,7 +151,7 @@ void CALSound::CacheMusic(const std::string &filename) { if (m_music.find(filename) == m_music.end()) { - auto buffer = MakeUnique(); + auto buffer = std::make_unique(); if (buffer->LoadFromFile(filename, static_cast(-1))) { m_music[filename] = std::move(buffer); @@ -246,7 +244,7 @@ bool CALSound::SearchFreeBuffer(SoundType sound, int &channel, bool &alreadyLoad // just add a new channel if we dont have any if (m_channels.size() == 0) { - auto chn = MakeUnique(); + auto chn = std::make_unique(); // check if we channel ready to play music, if not report error if (chn->IsReady()) { @@ -271,7 +269,7 @@ bool CALSound::SearchFreeBuffer(SoundType sound, int &channel, bool &alreadyLoad { if (m_channels.find(i) == m_channels.end()) { - auto chn = MakeUnique(); + auto chn = std::make_unique(); // check if channel is ready to play music, if not destroy it and seek free one if (chn->IsReady()) { @@ -597,7 +595,7 @@ void CALSound::PlayMusic(const std::string &filename, bool repeat, float fadeTim { GetLogger()->Debug("Music %s was not cached!\n", filename.c_str()); - auto newBuffer = MakeUnique(); + auto newBuffer = std::make_unique(); buffer = newBuffer.get(); if (!newBuffer->LoadFromFile(filename, static_cast(-1))) { @@ -620,7 +618,7 @@ void CALSound::PlayMusic(const std::string &filename, bool repeat, float fadeTim m_oldMusic.push_back(std::move(old)); } - m_currentMusic = MakeUnique(); + m_currentMusic = std::make_unique(); m_currentMusic->SetBuffer(buffer); m_currentMusic->SetVolume(m_musicVolume); m_currentMusic->SetLoop(repeat); diff --git a/src/ui/controls/edit.cpp b/src/ui/controls/edit.cpp index 8701c756..35a7fcf9 100644 --- a/src/ui/controls/edit.cpp +++ b/src/ui/controls/edit.cpp @@ -26,7 +26,6 @@ #include "app/input.h" #include "common/logger.h" -#include "common/make_unique.h" #include "common/stringutils.h" #include "common/resources/inputstream.h" @@ -186,7 +185,7 @@ bool CEdit::Create(const glm::vec2& pos, const glm::vec2& dim, int icon, EventTy { m_bMulti = true; MoveAdjust(); // readjusts multi-line mode - m_scroll = MakeUnique(); + m_scroll = std::make_unique(); m_scroll->Create(pos, dim, -1, EVENT_NULL); MoveAdjust(); } diff --git a/src/ui/controls/editvalue.cpp b/src/ui/controls/editvalue.cpp index 5a07e887..6dff4a9b 100644 --- a/src/ui/controls/editvalue.cpp +++ b/src/ui/controls/editvalue.cpp @@ -21,7 +21,6 @@ #include "ui/controls/editvalue.h" #include "common/event.h" -#include "common/make_unique.h" #include "level/robotmain.h" @@ -63,15 +62,15 @@ bool CEditValue::Create(const glm::vec2& pos, const glm::vec2& dim, int icon, Ev GlintDelete(); - m_edit = MakeUnique(); + m_edit = std::make_unique(); m_edit->Create(pos, dim, 0, EVENT_NULL); m_edit->SetMaxChar(4); - m_buttonUp = MakeUnique(); + m_buttonUp = std::make_unique(); m_buttonUp->Create(pos, dim, 49, EVENT_NULL); // ^ m_buttonUp->SetRepeat(true); - m_buttonDown = MakeUnique(); + m_buttonDown = std::make_unique(); m_buttonDown->Create(pos, dim, 50, EVENT_NULL); // v m_buttonDown->SetRepeat(true); diff --git a/src/ui/controls/interface.cpp b/src/ui/controls/interface.cpp index efcbaf5d..8d7b352e 100644 --- a/src/ui/controls/interface.cpp +++ b/src/ui/controls/interface.cpp @@ -95,7 +95,7 @@ ControlClass* CInterface::CreateControl(const glm::vec2& pos, const glm::vec2& d if (index < 0) return nullptr; - auto control = MakeUnique(); + auto control = std::make_unique(); control->Create(pos, dim, icon, eventMsg); auto* controlPtr = control.get(); m_controls[index] = std::move(control); @@ -130,7 +130,7 @@ CWindow* CInterface::CreateWindows(const glm::vec2& pos, const glm::vec2& dim, i if (index < 0) return nullptr; - auto window = MakeUnique(); + auto window = std::make_unique(); window->Create(pos, dim, icon, eventMsg); auto* windowPtr = window.get(); m_controls[index] = std::move(window); @@ -237,7 +237,7 @@ CList* CInterface::CreateList(const glm::vec2& pos, const glm::vec2& dim, int ic if (index < 0) return nullptr; - auto list = MakeUnique(); + auto list = std::make_unique(); list->Create(pos, dim, icon, eventMsg, expand); auto* listPtr = list.get(); m_controls[index] = std::move(list); diff --git a/src/ui/controls/list.cpp b/src/ui/controls/list.cpp index 553a2989..82acd19f 100644 --- a/src/ui/controls/list.cpp +++ b/src/ui/controls/list.cpp @@ -20,8 +20,6 @@ #include "ui/controls/list.h" -#include "common/make_unique.h" - #include "graphics/core/device.h" #include "graphics/core/renderers.h" #include "graphics/core/transparency.h" @@ -82,7 +80,7 @@ bool CList::Create(const glm::vec2& pos, const glm::vec2& dim, int icon, EventTy CControl::Create(pos, dim, icon, eventMsg); - m_scroll = MakeUnique(); + m_scroll = std::make_unique(); m_scroll->Create(pos, dim, 0, EVENT_NULL); return MoveAdjust(); @@ -140,7 +138,7 @@ bool CList::MoveAdjust() ddim.y = h; for (int i = 0; i < m_displayLine; i++) { - auto button = MakeUnique(); + auto button = std::make_unique(); button->Create(ppos, ddim, -1, EVENT_NULL); button->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); button->SetState(STATE_SIMPLY); diff --git a/src/ui/controls/scroll.cpp b/src/ui/controls/scroll.cpp index d2149e7e..1cd6f141 100644 --- a/src/ui/controls/scroll.cpp +++ b/src/ui/controls/scroll.cpp @@ -21,7 +21,6 @@ #include "ui/controls/scroll.h" #include "common/event.h" -#include "common/make_unique.h" #include "graphics/core/device.h" #include "graphics/core/renderers.h" @@ -94,14 +93,14 @@ void CScroll::MoveAdjust() { if (m_buttonUp == nullptr) { - m_buttonUp = MakeUnique(); + m_buttonUp = std::make_unique(); m_buttonUp->Create({ 0.0f, 0.0f }, { 0.0f, 0.0f }, 49, EVENT_NULL); m_buttonUp->SetRepeat(true); } if (m_buttonDown == nullptr) { - m_buttonDown = MakeUnique(); + m_buttonDown = std::make_unique(); m_buttonDown->Create({ 0.0f, 0.0f }, { 0.0f, 0.0f }, 50, EVENT_NULL); m_buttonDown->SetRepeat(true); } diff --git a/src/ui/controls/slider.cpp b/src/ui/controls/slider.cpp index 8ef90415..39fd0586 100644 --- a/src/ui/controls/slider.cpp +++ b/src/ui/controls/slider.cpp @@ -108,7 +108,7 @@ void CSlider::MoveAdjust() { if (m_buttonLeft == nullptr) { - m_buttonLeft = MakeUnique(); + m_buttonLeft = std::make_unique(); m_buttonLeft->Create({ 0.0f, 0.0f }, { 0.0f, 0.0f }, m_bHoriz ? 55 : 49, EVENT_NULL); // SetRepeat(true); if ( m_state & STATE_SHADOW ) m_buttonLeft->SetState(STATE_SHADOW); @@ -116,7 +116,7 @@ void CSlider::MoveAdjust() if (m_buttonRight == nullptr) { - m_buttonRight = MakeUnique(); + m_buttonRight = std::make_unique(); m_buttonRight->Create({ 0.0f, 0.0f }, { 0.0f, 0.0f }, m_bHoriz ? 48 : 50, EVENT_NULL); // >/v m_buttonRight->SetRepeat(true); if ( m_state & STATE_SHADOW ) m_buttonRight->SetState(STATE_SHADOW); diff --git a/src/ui/controls/window.cpp b/src/ui/controls/window.cpp index 1ddcb9d5..db77af83 100644 --- a/src/ui/controls/window.cpp +++ b/src/ui/controls/window.cpp @@ -103,7 +103,7 @@ bool CWindow::Create(const glm::vec2& pos, const glm::vec2& dim, int icon, Event template ControlClass* CWindow::CreateControl(const glm::vec2& pos, const glm::vec2& dim, int icon, EventType eventMsg) { - auto control = MakeUnique(); + auto control = std::make_unique(); control->Create(pos, dim, icon, eventMsg); auto* controlPtr = control.get(); m_controls.push_back(std::move(control)); @@ -220,7 +220,7 @@ CList* CWindow::CreateList(const glm::vec2& pos, const glm::vec2& dim, int icon, if (eventMsg == EVENT_NULL) eventMsg = GetUniqueEventType(); - auto list = MakeUnique(); + auto list = std::make_unique(); list->Create(pos, dim, icon, eventMsg, expand); auto* listPtr = list.get(); m_controls.push_back(std::move(list)); @@ -351,10 +351,10 @@ void CWindow::SetName(std::string name, bool tooltip) if ( m_name.length() > 0 && m_bRedim ) // title bar exists? { - m_buttonReduce = MakeUnique(); + m_buttonReduce = std::make_unique(); m_buttonReduce->Create(m_pos, m_dim, 0, EVENT_NULL); - m_buttonFull = MakeUnique(); + m_buttonFull = std::make_unique(); m_buttonFull->Create(m_pos, m_dim, 0, EVENT_NULL); bAdjust = true; @@ -362,7 +362,7 @@ void CWindow::SetName(std::string name, bool tooltip) if ( m_name.length() > 0 && m_bClosable ) // title bar exists? { - m_buttonClose = MakeUnique(); + m_buttonClose = std::make_unique(); m_buttonClose->Create(m_pos, m_dim, 0, EVENT_NULL); bAdjust = true; diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index eb746df3..472494fd 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -26,7 +26,6 @@ #include "common/event.h" #include "common/logger.h" -#include "common/make_unique.h" #include "common/settings.h" #include "graphics/engine/engine.h" diff --git a/src/ui/mainui.cpp b/src/ui/mainui.cpp index a82ed74e..65f88a4d 100644 --- a/src/ui/mainui.cpp +++ b/src/ui/mainui.cpp @@ -24,7 +24,6 @@ #include "common/event.h" #include "common/logger.h" -#include "common/make_unique.h" #include "common/settings.h" #include "common/resources/resourcemanager.h" @@ -80,24 +79,24 @@ CMainUserInterface::CMainUserInterface() m_sound = m_app->GetSound(); m_settings = CSettings::GetInstancePointer(); - m_dialog = MakeUnique(); + m_dialog = std::make_unique(); - m_screenAppearance = MakeUnique(); - m_screenLevelList = MakeUnique(m_dialog.get()); - m_screenIORead = MakeUnique(m_screenLevelList.get()); - m_screenIOWrite = MakeUnique(m_screenLevelList.get()); - m_screenLoading = MakeUnique(); - m_screenModList = MakeUnique(m_dialog.get(), m_app->GetModManager()); - m_screenSetupControls = MakeUnique(); - m_screenSetupDisplay = MakeUnique(); - m_screenSetupGame = MakeUnique(); - m_screenSetupGraphics = MakeUnique(); - m_screenSetupSound = MakeUnique(); - m_screenMainMenu = MakeUnique(); - m_screenPlayerSelect = MakeUnique(m_dialog.get()); - m_screenQuit = MakeUnique(); - m_screenWelcome = MakeUnique(); - m_mouseParticlesGenerator = MakeUnique(); + m_screenAppearance = std::make_unique(); + m_screenLevelList = std::make_unique(m_dialog.get()); + m_screenIORead = std::make_unique(m_screenLevelList.get()); + m_screenIOWrite = std::make_unique(m_screenLevelList.get()); + m_screenLoading = std::make_unique(); + m_screenModList = std::make_unique(m_dialog.get(), m_app->GetModManager()); + m_screenSetupControls = std::make_unique(); + m_screenSetupDisplay = std::make_unique(); + m_screenSetupGame = std::make_unique(); + m_screenSetupGraphics = std::make_unique(); + m_screenSetupSound = std::make_unique(); + m_screenMainMenu = std::make_unique(); + m_screenPlayerSelect = std::make_unique(m_dialog.get()); + m_screenQuit = std::make_unique(); + m_screenWelcome = std::make_unique(); + m_mouseParticlesGenerator = std::make_unique(); m_currentScreen = nullptr; diff --git a/src/ui/object_interface.cpp b/src/ui/object_interface.cpp index 9ba98e30..dac5fdc1 100644 --- a/src/ui/object_interface.cpp +++ b/src/ui/object_interface.cpp @@ -740,7 +740,7 @@ void CObjectInterface::StartEditScript(Program* program, std::string name) { CreateInterface(false); // removes the control buttons - m_studio = MakeUnique(); + m_studio = std::make_unique(); m_studio->StartEditScript(program->script.get(), name, program); } diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp index fe646688..0ec5ed9e 100644 --- a/src/ui/studio.cpp +++ b/src/ui/studio.cpp @@ -984,12 +984,12 @@ void CStudio::StartDialog(const Event &event) { if ( event.type == EVENT_STUDIO_OPEN ) { - m_fileDialog = MakeUnique(); + m_fileDialog = std::make_unique(); m_fileDialog->SetDialogType(CFileDialog::Type::Open); } if ( event.type == EVENT_STUDIO_SAVE ) { - m_fileDialog = MakeUnique(); + m_fileDialog = std::make_unique(); m_fileDialog->SetDialogType(CFileDialog::Type::Save); } diff --git a/test/unit/app/app_test.cpp b/test/unit/app/app_test.cpp index e62b24ed..9dfd0e06 100644 --- a/test/unit/app/app_test.cpp +++ b/test/unit/app/app_test.cpp @@ -19,8 +19,6 @@ #include "app/app.h" -#include "common/make_unique.h" - #include "common/system/system_other.h" #include @@ -40,7 +38,7 @@ public: : CApplication(systemUtils) { SDL_Init(0); - m_eventQueue = MakeUnique(); + m_eventQueue = std::make_unique(); } ~CApplicationWrapper() @@ -95,7 +93,7 @@ void CApplicationUT::SetUp() m_mocks.OnCall(m_systemUtils, CSystemUtils::GetCurrentTimeStamp).Do(std::bind(&CApplicationUT::GetCurrentTimeStamp, this)); - m_app = MakeUnique(m_systemUtils); + m_app = std::make_unique(m_systemUtils); } void CApplicationUT::TearDown()