diff --git a/source/collada/StdSkeletons.cpp b/source/collada/StdSkeletons.cpp index ef57528048..8d1339231a 100644 --- a/source/collada/StdSkeletons.cpp +++ b/source/collada/StdSkeletons.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -148,7 +148,7 @@ namespace for (xmlNodeList::iterator skeletonNode = skeletonNodes.begin(); skeletonNode != skeletonNodes.end(); ++skeletonNode) { - std::unique_ptr skeleton (new Skeleton()); + std::unique_ptr skeleton = std::make_unique(); std::string title (FUXmlParser::ReadNodeProperty(*skeletonNode, "title")); diff --git a/source/graphics/ModelDef.cpp b/source/graphics/ModelDef.cpp index 25b5c376f0..fc185f95ba 100644 --- a/source/graphics/ModelDef.cpp +++ b/source/graphics/ModelDef.cpp @@ -280,7 +280,7 @@ CModelDef* CModelDef::Load(const VfsPath& filename, const VfsPath& name) throw PSERROR_File_InvalidVersion(); } - std::unique_ptr mdef (new CModelDef()); + std::unique_ptr mdef = std::make_unique(); mdef->m_Name = name; // now unpack everything diff --git a/source/graphics/ShaderDefines.cpp b/source/graphics/ShaderDefines.cpp index dfe8ea7c17..66cb515689 100644 --- a/source/graphics/ShaderDefines.cpp +++ b/source/graphics/ShaderDefines.cpp @@ -91,7 +91,7 @@ typename CShaderParams::SItems* CShaderParams::GetInterned(con typedef ItemNameCmp Cmp; ENSURE(std::adjacent_find(items.items.begin(), items.items.end(), std::binary_negate(Cmp())) == items.items.end()); - shared_ptr ptr(new SItems(items)); + shared_ptr ptr = std::make_shared(items); s_InternedItems.insert(std::make_pair(items, ptr)); return ptr.get(); } diff --git a/source/graphics/TextureConverter.cpp b/source/graphics/TextureConverter.cpp index 964d3f29c9..417b65f1a3 100644 --- a/source/graphics/TextureConverter.cpp +++ b/source/graphics/TextureConverter.cpp @@ -139,7 +139,7 @@ CTextureConverter::SettingsFile* CTextureConverter::LoadSettings(const VfsPath& return NULL; } - std::unique_ptr settings(new SettingsFile()); + std::unique_ptr settings = std::make_unique(); XERO_ITER_EL(root, child) { @@ -385,7 +385,7 @@ bool CTextureConverter::ConvertTexture(const CTexturePtr& texture, const VfsPath #if CONFIG2_NVTT - shared_ptr request(new ConversionRequest); + shared_ptr request = std::make_shared(); request->dest = dest; request->texture = texture; @@ -572,7 +572,7 @@ void CTextureConverter::RunThread(CTextureConverter* textureConverter) } // Set up the result object - shared_ptr result(new ConversionResult()); + shared_ptr result = std::make_shared(); result->dest = request->dest; result->texture = request->texture; diff --git a/source/gui/CGUI.cpp b/source/gui/CGUI.cpp index aae06098d1..e7b8fc75a6 100644 --- a/source/gui/CGUI.cpp +++ b/source/gui/CGUI.cpp @@ -66,7 +66,7 @@ const CStr CGUI::EventNameMouseRightDoubleClick = "MouseRightDoubleClick"; const CStr CGUI::EventNameMouseRightRelease = "MouseRightRelease"; CGUI::CGUI(const shared_ptr& context) - : m_BaseObject(new CGUIDummyObject(*this)), + : m_BaseObject(std::make_unique(*this)), m_FocusedObject(nullptr), m_InternalNameNumber(0), m_MouseButtons(0) diff --git a/source/i18n/L10n.cpp b/source/i18n/L10n.cpp index 78969a0d64..890ca30f57 100644 --- a/source/i18n/L10n.cpp +++ b/source/i18n/L10n.cpp @@ -507,7 +507,7 @@ void L10n::LoadListOfAvailableLocales() std::string filename = utf8_from_wstring(path.string()).substr(strlen("l10n/")); size_t lengthToFirstDot = filename.find('.'); std::string localeCode = filename.substr(0, lengthToFirstDot); - std::unique_ptr locale(new icu::Locale(icu::Locale::createCanonical(localeCode.c_str()))); + std::unique_ptr locale = std::make_unique(icu::Locale::createCanonical(localeCode.c_str())); auto it = std::find_if(availableLocales.begin(), availableLocales.end(), [&locale](const std::unique_ptr& l) { return *locale == *l; }); diff --git a/source/lib/file/archive/archive_zip.cpp b/source/lib/file/archive/archive_zip.cpp index 88fddd0e89..a7b5fba4de 100644 --- a/source/lib/file/archive/archive_zip.cpp +++ b/source/lib/file/archive/archive_zip.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2020 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -472,7 +472,7 @@ public: { const OsPath name = relativePathname.Filename(); CFileInfo fileInfo(name, cdfh->USize(), cdfh->MTime()); - shared_ptr archiveFile(new ArchiveFile_Zip(m_file, cdfh->HeaderOffset(), cdfh->CSize(), cdfh->Checksum(), cdfh->Method())); + shared_ptr archiveFile = std::make_shared(m_file, cdfh->HeaderOffset(), cdfh->CSize(), cdfh->Checksum(), cdfh->Method()); cb(relativePathname, fileInfo, archiveFile, cbData); } @@ -548,7 +548,7 @@ private: // for this: // 1) Header file format and size differ from what we expect // 2) File has been truncated - // 3) The magic id occurs inside a zip comment + // 3) The magic id occurs inside a zip comment ecdr = nullptr; } else diff --git a/source/ps/CStrIntern.cpp b/source/ps/CStrIntern.cpp index cf82caf5b6..9d422baaed 100644 --- a/source/ps/CStrIntern.cpp +++ b/source/ps/CStrIntern.cpp @@ -105,7 +105,7 @@ static CStrInternInternals* GetString(const char* str, size_t len) if (it != g_Strings.end()) return it->second.get(); - shared_ptr internals(new CStrInternInternals(str, len)); + shared_ptr internals = std::make_shared(str, len); g_Strings.insert(std::make_pair(internals->data, internals)); return internals.get(); } diff --git a/source/ps/UserReport.cpp b/source/ps/UserReport.cpp index 7e86053e5e..a4005a2f8f 100644 --- a/source/ps/UserReport.cpp +++ b/source/ps/UserReport.cpp @@ -629,7 +629,7 @@ void CUserReporter::SubmitReport(const std::string& type, int version, const std return; // Actual submit - shared_ptr report(new CUserReport); + shared_ptr report = std::make_shared(); report->m_Time = time(NULL); report->m_Type = type; report->m_Version = version; diff --git a/source/ps/XML/RelaxNG.cpp b/source/ps/XML/RelaxNG.cpp index 49cb6cb7be..a09688cef6 100644 --- a/source/ps/XML/RelaxNG.cpp +++ b/source/ps/XML/RelaxNG.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -98,7 +98,7 @@ bool RelaxNGValidator::LoadGrammar(const std::string& grammar) std::map >::iterator it = g_SchemaCache.find(grammar); if (it == g_SchemaCache.end()) { - schema = shared_ptr(new RelaxNGSchema(grammar)); + schema = std::make_shared(grammar); g_SchemaCache[grammar] = schema; } else diff --git a/source/renderer/OverlayRenderer.cpp b/source/renderer/OverlayRenderer.cpp index 3ebc0087a2..0f1b1f3224 100644 --- a/source/renderer/OverlayRenderer.cpp +++ b/source/renderer/OverlayRenderer.cpp @@ -285,7 +285,7 @@ void OverlayRenderer::PrepareForRendering() SOverlayTexturedLine* line = m->texlines[i]; if (!line->m_RenderData) { - line->m_RenderData = shared_ptr(new CTexturedLineRData()); + line->m_RenderData = std::make_shared(); line->m_RenderData->Update(*line); // We assume the overlay line will get replaced by the caller // if terrain changes, so we don't need to detect that here and diff --git a/source/scriptinterface/ScriptContext.cpp b/source/scriptinterface/ScriptContext.cpp index bce54bfcf8..e90b79cee9 100644 --- a/source/scriptinterface/ScriptContext.cpp +++ b/source/scriptinterface/ScriptContext.cpp @@ -78,7 +78,7 @@ void GCSliceCallbackHook(JSContext* UNUSED(cx), JS::GCProgress progress, const J shared_ptr ScriptContext::CreateContext(int contextSize, int heapGrowthBytesGCTrigger) { - return shared_ptr(new ScriptContext(contextSize, heapGrowthBytesGCTrigger)); + return std::make_shared(contextSize, heapGrowthBytesGCTrigger); } ScriptContext::ScriptContext(int contextSize, int heapGrowthBytesGCTrigger): diff --git a/source/scriptinterface/ScriptInterface.cpp b/source/scriptinterface/ScriptInterface.cpp index 932cee803b..a8b1567673 100644 --- a/source/scriptinterface/ScriptInterface.cpp +++ b/source/scriptinterface/ScriptInterface.cpp @@ -365,7 +365,7 @@ void ScriptInterface_impl::Register(const char* name, JSNative fptr, uint nargs) } ScriptInterface::ScriptInterface(const char* nativeScopeName, const char* debugName, const shared_ptr& context) : - m(new ScriptInterface_impl(nativeScopeName, context)) + m(std::make_unique(nativeScopeName, context)) { // Profiler stats table isn't thread-safe, so only enable this on the main thread if (Threading::IsMainThread()) diff --git a/source/simulation2/Simulation2.cpp b/source/simulation2/Simulation2.cpp index 17b802e41a..eee776c482 100644 --- a/source/simulation2/Simulation2.cpp +++ b/source/simulation2/Simulation2.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2020 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -430,7 +430,7 @@ void CSimulation2Impl::Update(int turnLength, const std::vector mapReader(new CMapReader); + std::unique_ptr mapReader = std::make_unique(); std::string mapType; scriptInterface.GetProperty(m_InitAttributes, "mapType", mapType); diff --git a/source/simulation2/components/CCmpAIManager.cpp b/source/simulation2/components/CCmpAIManager.cpp index 24810be130..a47ec98ebb 100644 --- a/source/simulation2/components/CCmpAIManager.cpp +++ b/source/simulation2/components/CCmpAIManager.cpp @@ -472,7 +472,7 @@ public: bool AddPlayer(const std::wstring& aiName, player_id_t player, u8 difficulty, const std::wstring& behavior) { - shared_ptr ai(new CAIPlayer(*this, aiName, player, difficulty, behavior, m_ScriptInterface)); + shared_ptr ai = std::make_shared(*this, aiName, player, difficulty, behavior, m_ScriptInterface); if (!ai->Initialise()) return false; diff --git a/source/simulation2/components/CCmpPathfinder.cpp b/source/simulation2/components/CCmpPathfinder.cpp index 1785607709..74b6438d61 100644 --- a/source/simulation2/components/CCmpPathfinder.cpp +++ b/source/simulation2/components/CCmpPathfinder.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2020 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -57,9 +57,9 @@ void CCmpPathfinder::Init(const CParamNode& UNUSED(paramNode)) m_AtlasOverlay = NULL; - m_VertexPathfinder = std::unique_ptr(new VertexPathfinder(m_MapSize, m_TerrainOnlyGrid)); - m_LongPathfinder = std::unique_ptr(new LongPathfinder()); - m_PathfinderHier = std::unique_ptr(new HierarchicalPathfinder()); + m_VertexPathfinder = std::make_unique(m_MapSize, m_TerrainOnlyGrid); + m_LongPathfinder = std::make_unique(); + m_PathfinderHier = std::make_unique(); // Register Relax NG validator CXeromyces::AddValidator(g_VFS, "pathfinder", "simulation/data/pathfinder.rng"); diff --git a/source/simulation2/components/CCmpRangeOverlayRenderer.cpp b/source/simulation2/components/CCmpRangeOverlayRenderer.cpp index 87ddc10631..499c166690 100644 --- a/source/simulation2/components/CCmpRangeOverlayRenderer.cpp +++ b/source/simulation2/components/CCmpRangeOverlayRenderer.cpp @@ -196,7 +196,7 @@ private: CVector2D origin; cmpPosition->GetInterpolatedPosition2D(frameOffset, origin.X, origin.Y, rotY); - rangeOverlay.line = std::unique_ptr(new SOverlayTexturedLine); + rangeOverlay.line = std::make_unique(); rangeOverlay.line->m_SimContext = &GetSimContext(); rangeOverlay.line->m_Color = m_Color; rangeOverlay.line->CreateOverlayTexture(&rangeOverlay.descriptor); diff --git a/source/simulation2/components/tests/test_Pathfinder.h b/source/simulation2/components/tests/test_Pathfinder.h index 7bd459f6d8..98b3756e58 100644 --- a/source/simulation2/components/tests/test_Pathfinder.h +++ b/source/simulation2/components/tests/test_Pathfinder.h @@ -144,7 +144,7 @@ public: sim2.LoadDefaultScripts(); sim2.ResetState(); - std::unique_ptr mapReader(new CMapReader()); + std::unique_ptr mapReader = std::make_unique(); LDR_BeginRegistering(); mapReader->LoadMap(L"maps/skirmishes/Median Oasis (2).pmp", @@ -255,7 +255,7 @@ public: sim2.LoadDefaultScripts(); sim2.ResetState(); - std::unique_ptr mapReader(new CMapReader()); + std::unique_ptr mapReader = std::make_unique(); LDR_BeginRegistering(); mapReader->LoadMap(L"maps/scenarios/Peloponnese.pmp", @@ -312,7 +312,7 @@ public: sim2.LoadDefaultScripts(); sim2.ResetState(); - std::unique_ptr mapReader(new CMapReader()); + std::unique_ptr mapReader = std::make_unique(); LDR_BeginRegistering(); mapReader->LoadMap(L"maps/scenarios/Peloponnese.pmp", diff --git a/source/simulation2/system/ComponentManager.cpp b/source/simulation2/system/ComponentManager.cpp index 6f86e8491b..7c444f79b5 100644 --- a/source/simulation2/system/ComponentManager.cpp +++ b/source/simulation2/system/ComponentManager.cpp @@ -254,7 +254,7 @@ void CComponentManager::Script_RegisterComponentType_Common(ScriptInterface::Cmp ctWrapper.dealloc, cname, schema, - std::unique_ptr(new JS::PersistentRootedValue(rq.cx, ctor)) + std::make_unique(rq.cx, ctor) }; componentManager->m_ComponentTypesById[cid] = std::move(ct); diff --git a/source/simulation2/tests/test_Serializer.h b/source/simulation2/tests/test_Serializer.h index 8118e3918b..581a0988a8 100644 --- a/source/simulation2/tests/test_Serializer.h +++ b/source/simulation2/tests/test_Serializer.h @@ -889,7 +889,7 @@ public: sim2.LoadDefaultScripts(); sim2.ResetState(); - std::unique_ptr mapReader(new CMapReader()); + std::unique_ptr mapReader = std::make_unique(); LDR_BeginRegistering(); mapReader->LoadMap(L"maps/skirmishes/Greek Acropolis (2).pmp", diff --git a/source/soundmanager/data/ogg.cpp b/source/soundmanager/data/ogg.cpp index 24d2aee205..52a6a02643 100644 --- a/source/soundmanager/data/ogg.cpp +++ b/source/soundmanager/data/ogg.cpp @@ -310,7 +310,7 @@ Status OpenOggStream(const OsPath& pathname, OggStreamPtr& stream) PFile file(new File); RETURN_STATUS_IF_ERR(file->Open(pathname, L'r')); - shared_ptr > tmp(new OggStreamImpl(VorbisFileAdapter(file))); + shared_ptr> tmp = std::make_shared>(VorbisFileAdapter(file)); RETURN_STATUS_IF_ERR(tmp->Open()); stream = tmp; return INFO::OK; @@ -322,7 +322,7 @@ Status OpenOggNonstream(const PIVFS& vfs, const VfsPath& pathname, OggStreamPtr& size_t size; RETURN_STATUS_IF_ERR(vfs->LoadFile(pathname, contents, size)); - shared_ptr > tmp(new OggStreamImpl(VorbisBufferAdapter(contents, size))); + shared_ptr> tmp = std::make_shared>(VorbisBufferAdapter(contents, size)); RETURN_STATUS_IF_ERR(tmp->Open()); stream = tmp; return INFO::OK;