From a95b6e050ac1eb91071dce232a80e74f69f76255 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Sun, 29 May 2022 13:24:32 +0200 Subject: [PATCH 1/4] Replace new with make_unique in components --- components/myguiplatform/myguidatamanager.cpp | 3 +-- components/nifbullet/bulletnifloader.cpp | 12 ++++++------ components/resource/resourcesystem.cpp | 8 ++++---- components/sceneutil/skeleton.cpp | 2 +- components/terrain/quadtreeworld.cpp | 2 +- components/terrain/world.cpp | 6 +++--- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/components/myguiplatform/myguidatamanager.cpp b/components/myguiplatform/myguidatamanager.cpp index 62023c8366..b01c5bbcf6 100644 --- a/components/myguiplatform/myguidatamanager.cpp +++ b/components/myguiplatform/myguidatamanager.cpp @@ -21,8 +21,7 @@ void DataManager::setResourcePath(const std::string &path) MyGUI::IDataStream *DataManager::getData(const std::string &name) const { std::string fullpath = getDataPath(name); - std::unique_ptr stream; - stream.reset(new std::ifstream); + auto stream = std::make_unique(); stream->open(fullpath, std::ios::binary); if (stream->fail()) { diff --git a/components/nifbullet/bulletnifloader.cpp b/components/nifbullet/bulletnifloader.cpp index 52be8d4a07..364f79e98e 100644 --- a/components/nifbullet/bulletnifloader.cpp +++ b/components/nifbullet/bulletnifloader.cpp @@ -140,7 +140,7 @@ std::monostate fillTriangleMesh(std::unique_ptr& mesh, const Nif return handleNiGeometry(geometry, [&] (const auto& data) { if (mesh == nullptr) - mesh.reset(new btTriangleMesh(false)); + mesh = std::make_unique(false); fillTriangleMesh(*mesh, data, transform); return std::monostate {}; }); @@ -150,7 +150,7 @@ std::unique_ptr makeChildMesh(const Nif::NiGeometry& geometry) { return handleNiGeometry(geometry, [&] (const auto& data) { - std::unique_ptr mesh(new btTriangleMesh); + auto mesh = std::make_unique(); fillTriangleMesh(*mesh, data, osg::Matrixf()); return mesh; }); @@ -197,8 +197,8 @@ osg::ref_ptr BulletNifLoader::load(const Nif::File& nif) { const btVector3 extents = Misc::Convert::toBullet(mShape->mCollisionBox.mExtents); const btVector3 center = Misc::Convert::toBullet(mShape->mCollisionBox.mCenter); - std::unique_ptr compound (new btCompoundShape); - std::unique_ptr boxShape(new btBoxShape(extents)); + auto compound = std::make_unique(); + auto boxShape = std::make_unique(extents); btTransform transform = btTransform::getIdentity(); transform.setOrigin(center); compound->addChildShape(transform, boxShape.get()); @@ -226,7 +226,7 @@ osg::ref_ptr BulletNifLoader::load(const Nif::File& nif) { btTransform trans; trans.setIdentity(); - std::unique_ptr child(new Resource::TriangleMeshShape(mStaticMesh.get(), true)); + std::unique_ptr child = std::make_unique(mStaticMesh.get(), true); mCompoundShape->addChildShape(trans, child.get()); child.release(); mStaticMesh.release(); @@ -407,7 +407,7 @@ void BulletNifLoader::handleNiTriShape(const Nif::NiGeometry& niGeometry, const if (!mCompoundShape) mCompoundShape.reset(new btCompoundShape); - std::unique_ptr childShape(new Resource::TriangleMeshShape(childMesh.get(), true)); + auto childShape = std::make_unique(childMesh.get(), true); childMesh.release(); float scale = niGeometry.trafo.scale; diff --git a/components/resource/resourcesystem.cpp b/components/resource/resourcesystem.cpp index ab9d0aba2c..a62dd0016a 100644 --- a/components/resource/resourcesystem.cpp +++ b/components/resource/resourcesystem.cpp @@ -13,10 +13,10 @@ namespace Resource ResourceSystem::ResourceSystem(const VFS::Manager *vfs) : mVFS(vfs) { - mNifFileManager.reset(new NifFileManager(vfs)); - mImageManager.reset(new ImageManager(vfs)); - mSceneManager.reset(new SceneManager(vfs, mImageManager.get(), mNifFileManager.get())); - mKeyframeManager.reset(new KeyframeManager(vfs, mSceneManager.get())); + mNifFileManager = std::make_unique(vfs); + mImageManager = std::make_unique(vfs); + mSceneManager = std::make_unique(vfs, mImageManager.get(), mNifFileManager.get()); + mKeyframeManager = std::make_unique(vfs, mSceneManager.get()); addResourceManager(mNifFileManager.get()); addResourceManager(mKeyframeManager.get()); diff --git a/components/sceneutil/skeleton.cpp b/components/sceneutil/skeleton.cpp index c465333fb4..9f646ade5c 100644 --- a/components/sceneutil/skeleton.cpp +++ b/components/sceneutil/skeleton.cpp @@ -69,7 +69,7 @@ Bone* Skeleton::getBone(const std::string &name) if (!mRootBone.get()) { - mRootBone.reset(new Bone); + mRootBone = std::make_unique(); } Bone* bone = mRootBone.get(); diff --git a/components/terrain/quadtreeworld.cpp b/components/terrain/quadtreeworld.cpp index eba69ad42d..1266e440a3 100644 --- a/components/terrain/quadtreeworld.cpp +++ b/components/terrain/quadtreeworld.cpp @@ -287,7 +287,7 @@ QuadTreeWorld::QuadTreeWorld(osg::Group *parent, osg::Group *compileRoot, Resour if (mDebugTerrainChunks) { - mDebugChunkManager = std::unique_ptr(new DebugChunkManager(mResourceSystem->getSceneManager(), mStorage, borderMask)); + mDebugChunkManager = std::make_unique(mResourceSystem->getSceneManager(), mStorage, borderMask); addChunkManager(mDebugChunkManager.get()); } } diff --git a/components/terrain/world.cpp b/components/terrain/world.cpp index 582cc68b1b..186687b37d 100644 --- a/components/terrain/world.cpp +++ b/components/terrain/world.cpp @@ -41,10 +41,10 @@ World::World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSyst mParent->addChild(mTerrainRoot); - mTextureManager.reset(new TextureManager(mResourceSystem->getSceneManager())); - mChunkManager.reset(new ChunkManager(mStorage, mResourceSystem->getSceneManager(), mTextureManager.get(), mCompositeMapRenderer)); + mTextureManager = std::make_unique(mResourceSystem->getSceneManager()); + mChunkManager = std::make_unique(mStorage, mResourceSystem->getSceneManager(), mTextureManager.get(), mCompositeMapRenderer); mChunkManager->setNodeMask(nodeMask); - mCellBorder.reset(new CellBorder(this,mTerrainRoot.get(),borderMask,mResourceSystem->getSceneManager())); + mCellBorder = std::make_unique(this,mTerrainRoot.get(),borderMask,mResourceSystem->getSceneManager()); mResourceSystem->addResourceManager(mChunkManager.get()); mResourceSystem->addResourceManager(mTextureManager.get()); From 3c83117e995a0684ebc532f0fdb434121c77d5c3 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Sun, 29 May 2022 13:24:48 +0200 Subject: [PATCH 2/4] Replace new with make_unique in openmw --- apps/openmw/main.cpp | 3 +- apps/openmw/mwclass/activator.cpp | 4 +-- apps/openmw/mwclass/apparatus.cpp | 2 +- apps/openmw/mwclass/armor.cpp | 2 +- apps/openmw/mwclass/book.cpp | 6 ++-- apps/openmw/mwclass/clothing.cpp | 2 +- apps/openmw/mwclass/container.cpp | 14 ++++---- apps/openmw/mwclass/creature.cpp | 14 ++++---- apps/openmw/mwclass/door.cpp | 13 ++++---- apps/openmw/mwclass/ingredient.cpp | 2 +- apps/openmw/mwclass/light.cpp | 6 ++-- apps/openmw/mwclass/lockpick.cpp | 2 +- apps/openmw/mwclass/misc.cpp | 5 ++- apps/openmw/mwclass/npc.cpp | 18 +++++----- apps/openmw/mwclass/probe.cpp | 2 +- apps/openmw/mwclass/repair.cpp | 2 +- apps/openmw/mwclass/weapon.cpp | 2 +- apps/openmw/mwgui/bookpage.cpp | 2 +- apps/openmw/mwgui/inventorywindow.cpp | 4 +-- apps/openmw/mwgui/loadingscreen.cpp | 2 +- apps/openmw/mwgui/mapwindow.cpp | 12 +++---- apps/openmw/mwgui/race.cpp | 4 +-- apps/openmw/mwgui/savegamedialog.cpp | 2 +- apps/openmw/mwgui/videowidget.cpp | 4 +-- apps/openmw/mwgui/windowmanagerimp.cpp | 6 ++-- apps/openmw/mwmechanics/aiactivate.cpp | 2 +- apps/openmw/mwmechanics/aicombat.cpp | 6 ++-- apps/openmw/mwmechanics/aicombataction.cpp | 12 +++---- apps/openmw/mwmechanics/aiescort.cpp | 2 +- apps/openmw/mwmechanics/aifollow.cpp | 2 +- apps/openmw/mwmechanics/aipursue.cpp | 2 +- apps/openmw/mwmechanics/aisequence.cpp | 16 ++++----- apps/openmw/mwmechanics/aitravel.cpp | 2 +- apps/openmw/mwmechanics/aiwander.cpp | 2 +- apps/openmw/mwphysics/actor.cpp | 2 +- apps/openmw/mwphysics/physicssystem.cpp | 6 ++-- apps/openmw/mwrender/creatureanimation.cpp | 4 +-- apps/openmw/mwrender/localmap.cpp | 4 +-- apps/openmw/mwrender/renderingmanager.cpp | 38 +++++++++++----------- apps/openmw/mwrender/sky.cpp | 6 ++-- apps/openmw/mwrender/water.cpp | 2 +- apps/openmw/mwsound/movieaudiofactory.cpp | 2 +- apps/openmw/mwsound/openal_output.cpp | 4 +-- apps/openmw/mwworld/cellstore.cpp | 2 +- apps/openmw/mwworld/class.cpp | 10 +++--- apps/openmw/mwworld/scene.cpp | 2 +- apps/openmw/mwworld/worldimp.cpp | 16 ++++----- 47 files changed, 137 insertions(+), 142 deletions(-) diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 7800335ddb..632c3d4530 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -213,8 +213,7 @@ int runApplication(int argc, char *argv[]) osg::setNotifyHandler(new OSGLogHandler()); Files::ConfigurationManager cfgMgr; - std::unique_ptr engine; - engine.reset(new OMW::Engine(cfgMgr)); + std::unique_ptr engine = std::make_unique(cfgMgr); if (parseOptions(argc, argv, *engine, cfgMgr)) { diff --git a/apps/openmw/mwclass/activator.cpp b/apps/openmw/mwclass/activator.cpp index 2d386addb8..83d84254a3 100644 --- a/apps/openmw/mwclass/activator.cpp +++ b/apps/openmw/mwclass/activator.cpp @@ -119,12 +119,12 @@ namespace MWClass auto& prng = MWBase::Environment::get().getWorld()->getPrng(); const ESM::Sound *sound = store.get().searchRandom("WolfActivator", prng); - std::unique_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); + std::unique_ptr action = std::make_unique("#{sWerewolfRefusal}"); if(sound) action->setSound(sound->mId); return action; } - return std::unique_ptr(new MWWorld::NullAction); + return std::make_unique(); } diff --git a/apps/openmw/mwclass/apparatus.cpp b/apps/openmw/mwclass/apparatus.cpp index 99a2d7887b..57b59b5b9d 100644 --- a/apps/openmw/mwclass/apparatus.cpp +++ b/apps/openmw/mwclass/apparatus.cpp @@ -110,7 +110,7 @@ namespace MWClass std::unique_ptr Apparatus::use (const MWWorld::Ptr& ptr, bool force) const { - return std::unique_ptr(new MWWorld::ActionAlchemy(force)); + return std::make_unique(force); } MWWorld::Ptr Apparatus::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index da2420d94a..e86f0430f5 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -336,7 +336,7 @@ namespace MWClass std::unique_ptr Armor::use (const MWWorld::Ptr& ptr, bool force) const { - std::unique_ptr action(new MWWorld::ActionEquip(ptr, force)); + std::unique_ptr action = std::make_unique(ptr, force); action->setSound(getUpSoundId(ptr)); diff --git a/apps/openmw/mwclass/book.cpp b/apps/openmw/mwclass/book.cpp index 86a0c56b9b..5d4d723be9 100644 --- a/apps/openmw/mwclass/book.cpp +++ b/apps/openmw/mwclass/book.cpp @@ -63,13 +63,13 @@ namespace MWClass auto& prng = MWBase::Environment::get().getWorld()->getPrng(); const ESM::Sound *sound = store.get().searchRandom("WolfItem", prng); - std::unique_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); + std::unique_ptr action = std::make_unique("#{sWerewolfRefusal}"); if(sound) action->setSound(sound->mId); return action; } - return std::unique_ptr(new MWWorld::ActionRead(ptr)); + return std::make_unique(ptr); } std::string Book::getScript (const MWWorld::ConstPtr& ptr) const @@ -151,7 +151,7 @@ namespace MWClass std::unique_ptr Book::use (const MWWorld::Ptr& ptr, bool force) const { - return std::unique_ptr(new MWWorld::ActionRead(ptr)); + return std::make_unique(ptr); } MWWorld::Ptr Book::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp index 79c502d673..1dd048ca9f 100644 --- a/apps/openmw/mwclass/clothing.cpp +++ b/apps/openmw/mwclass/clothing.cpp @@ -230,7 +230,7 @@ namespace MWClass std::unique_ptr Clothing::use (const MWWorld::Ptr& ptr, bool force) const { - std::unique_ptr action(new MWWorld::ActionEquip(ptr, force)); + std::unique_ptr action = std::make_unique(ptr, force); action->setSound(getUpSoundId(ptr)); diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index ad0b6169a9..992d9b02d1 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -135,7 +135,7 @@ namespace MWClass const MWWorld::Ptr& actor) const { if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory)) - return std::unique_ptr (new MWWorld::NullAction ()); + return std::make_unique(); if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) { @@ -143,7 +143,7 @@ namespace MWClass auto& prng = MWBase::Environment::get().getWorld()->getPrng(); const ESM::Sound *sound = store.get().searchRandom("WolfContainer", prng); - std::unique_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); + std::unique_ptr action = std::make_unique("#{sWerewolfRefusal}"); if(sound) action->setSound(sound->mId); return action; @@ -191,24 +191,22 @@ namespace MWClass { if (canBeHarvested(ptr)) { - std::unique_ptr action (new MWWorld::ActionHarvest(ptr)); - return action; + return std::make_unique(ptr); } - std::unique_ptr action (new MWWorld::ActionOpen(ptr)); - return action; + return std::make_unique(ptr); } else { // Activate trap - std::unique_ptr action(new MWWorld::ActionTrap(ptr.getCellRef().getTrap(), ptr)); + std::unique_ptr action = std::make_unique(ptr.getCellRef().getTrap(), ptr); action->setSound(trapActivationSound); return action; } } else { - std::unique_ptr action(new MWWorld::FailedAction(std::string(), ptr)); + std::unique_ptr action = std::make_unique(std::string(), ptr); action->setSound(lockedSound); return action; } diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index fc3504b947..667942b320 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -439,7 +439,7 @@ namespace MWClass auto& prng = MWBase::Environment::get().getWorld()->getPrng(); const ESM::Sound *sound = store.get().searchRandom("WolfCreature", prng); - std::unique_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); + std::unique_ptr action = std::make_unique("#{sWerewolfRefusal}"); if(sound) action->setSound(sound->mId); return action; @@ -453,20 +453,20 @@ namespace MWClass // by default user can loot friendly actors during death animation if (canLoot && !stats.getAiSequence().isInCombat()) - return std::unique_ptr(new MWWorld::ActionOpen(ptr)); + return std::make_unique(ptr); // otherwise wait until death animation if(stats.isDeathAnimationFinished()) - return std::unique_ptr(new MWWorld::ActionOpen(ptr)); + return std::make_unique(ptr); } else if (!stats.getAiSequence().isInCombat() && !stats.getKnockedDown()) - return std::unique_ptr(new MWWorld::ActionTalk(ptr)); + return std::make_unique(ptr); // Tribunal and some mod companions oddly enough must use open action as fallback if (!getScript(ptr).empty() && ptr.getRefData().getLocals().getIntVar(getScript(ptr), "companion")) - return std::unique_ptr(new MWWorld::ActionOpen(ptr)); + return std::make_unique(ptr); - return std::unique_ptr(new MWWorld::FailedAction("")); + return std::make_unique(); } MWWorld::ContainerStore& Creature::getContainerStore (const MWWorld::Ptr& ptr) const @@ -763,7 +763,7 @@ namespace MWClass else { // Create a CustomData, but don't fill it from ESM records (not needed) - std::unique_ptr data (new CreatureCustomData); + auto data = std::make_unique(); if (hasInventoryStore(ptr)) data->mContainerStore = std::make_unique(); diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 8a044ffb4d..6fcd45b6ba 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -131,7 +131,7 @@ namespace MWClass // Make such activation a no-op for now, like how it is in the vanilla game. if (actor != MWMechanics::getPlayer() && ptr.getCellRef().getTeleport()) { - std::unique_ptr action(new MWWorld::FailedAction(std::string(), ptr)); + std::unique_ptr action = std::make_unique(std::string(), ptr); action->setSound(lockedSound); return action; } @@ -182,7 +182,7 @@ namespace MWClass if(isTrapped) { // Trap activation - std::unique_ptr action(new MWWorld::ActionTrap(ptr.getCellRef().getTrap(), ptr)); + std::unique_ptr action = std::make_unique(ptr.getCellRef().getTrap(), ptr); action->setSound(trapActivationSound); return action; } @@ -192,12 +192,11 @@ namespace MWClass if (actor == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getDistanceToFacedObject() > MWBase::Environment::get().getWorld()->getMaxActivationDistance()) { // player activated teleport door with telekinesis - std::unique_ptr action(new MWWorld::FailedAction); - return action; + return std::make_unique(); } else { - std::unique_ptr action(new MWWorld::ActionTeleport (ptr.getCellRef().getDestCell(), ptr.getCellRef().getDoorDest(), true)); + std::unique_ptr action = std::make_unique(ptr.getCellRef().getDestCell(), ptr.getCellRef().getDoorDest(), true); action->setSound(openSound); return action; } @@ -205,7 +204,7 @@ namespace MWClass else { // animated door - std::unique_ptr action(new MWWorld::ActionDoor(ptr)); + std::unique_ptr action = std::make_unique(ptr); const auto doorState = getDoorState(ptr); bool opening = true; float doorRot = ptr.getRefData().getPosition().rot[2] - ptr.getCellRef().getPosition().rot[2]; @@ -239,7 +238,7 @@ namespace MWClass else { // locked, and we can't open. - std::unique_ptr action(new MWWorld::FailedAction(std::string(), ptr)); + std::unique_ptr action = std::make_unique(std::string(), ptr); action->setSound(lockedSound); return action; } diff --git a/apps/openmw/mwclass/ingredient.cpp b/apps/openmw/mwclass/ingredient.cpp index 2331361477..e8e7f5bd3e 100644 --- a/apps/openmw/mwclass/ingredient.cpp +++ b/apps/openmw/mwclass/ingredient.cpp @@ -74,7 +74,7 @@ namespace MWClass std::unique_ptr Ingredient::use (const MWWorld::Ptr& ptr, bool force) const { - std::unique_ptr action (new MWWorld::ActionEat (ptr)); + std::unique_ptr action = std::make_unique(ptr); action->setSound ("Swallow"); diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index a7d49da54a..81256d06d3 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -89,11 +89,11 @@ namespace MWClass const MWWorld::Ptr& actor) const { if(!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory)) - return std::unique_ptr(new MWWorld::NullAction()); + return std::make_unique(); MWWorld::LiveCellRef *ref = ptr.get(); if(!(ref->mBase->mData.mFlags&ESM::Light::Carry)) - return std::unique_ptr(new MWWorld::FailedAction()); + return std::make_unique(); return defaultItemActivate(ptr, actor); } @@ -186,7 +186,7 @@ namespace MWClass std::unique_ptr Light::use (const MWWorld::Ptr& ptr, bool force) const { - std::unique_ptr action(new MWWorld::ActionEquip(ptr, force)); + std::unique_ptr action = std::make_unique(ptr, force); action->setSound(getUpSoundId(ptr)); diff --git a/apps/openmw/mwclass/lockpick.cpp b/apps/openmw/mwclass/lockpick.cpp index c8860df4ce..1d898381b9 100644 --- a/apps/openmw/mwclass/lockpick.cpp +++ b/apps/openmw/mwclass/lockpick.cpp @@ -126,7 +126,7 @@ namespace MWClass std::unique_ptr Lockpick::use (const MWWorld::Ptr& ptr, bool force) const { - std::unique_ptr action(new MWWorld::ActionEquip(ptr, force)); + std::unique_ptr action = std::make_unique(ptr, force); action->setSound(getUpSoundId(ptr)); diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index 51e75650fb..ac332cc47f 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -206,9 +206,8 @@ namespace MWClass std::unique_ptr Miscellaneous::use (const MWWorld::Ptr& ptr, bool force) const { if (ptr.getCellRef().getSoul().empty() || !MWBase::Environment::get().getWorld()->getStore().get().search(ptr.getCellRef().getSoul())) - return std::unique_ptr(new MWWorld::NullAction()); - else - return std::unique_ptr(new MWWorld::ActionSoulgem(ptr)); + return std::make_unique(); + return std::make_unique(ptr); } bool Miscellaneous::canSell (const MWWorld::ConstPtr& item, int npcServices) const diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index f3fcb848fd..297684de53 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -865,7 +865,7 @@ namespace MWClass { // player got activated by another NPC if(ptr == MWMechanics::getPlayer()) - return std::unique_ptr(new MWWorld::ActionTalk(actor)); + return std::make_unique(actor); // Werewolfs can't activate NPCs if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) @@ -874,7 +874,7 @@ namespace MWClass auto& prng = MWBase::Environment::get().getWorld()->getPrng(); const ESM::Sound *sound = store.get().searchRandom("WolfNPC", prng); - std::unique_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); + std::unique_ptr action = std::make_unique("#{sWerewolfRefusal}"); if(sound) action->setSound(sound->mId); return action; @@ -888,33 +888,33 @@ namespace MWClass // by default user can loot friendly actors during death animation if (canLoot && !stats.getAiSequence().isInCombat()) - return std::unique_ptr(new MWWorld::ActionOpen(ptr)); + return std::make_unique(ptr); // otherwise wait until death animation if(stats.isDeathAnimationFinished()) - return std::unique_ptr(new MWWorld::ActionOpen(ptr)); + return std::make_unique(ptr); } else if (!stats.getAiSequence().isInCombat()) { if (stats.getKnockedDown() || MWBase::Environment::get().getMechanicsManager()->isSneaking(actor)) - return std::unique_ptr(new MWWorld::ActionOpen(ptr)); // stealing + return std::make_unique(ptr); // stealing // Can't talk to werewolves if (!getNpcStats(ptr).isWerewolf()) - return std::unique_ptr(new MWWorld::ActionTalk(ptr)); + return std::make_unique(ptr); } else // In combat { const bool stealingInCombat = Settings::Manager::getBool ("always allow stealing from knocked out actors", "Game"); if (stealingInCombat && stats.getKnockedDown()) - return std::unique_ptr(new MWWorld::ActionOpen(ptr)); // stealing + return std::make_unique(ptr); // stealing } // Tribunal and some mod companions oddly enough must use open action as fallback if (!getScript(ptr).empty() && ptr.getRefData().getLocals().getIntVar(getScript(ptr), "companion")) - return std::unique_ptr(new MWWorld::ActionOpen(ptr)); + return std::make_unique(ptr); - return std::unique_ptr (new MWWorld::FailedAction("")); + return std::make_unique(); } MWWorld::ContainerStore& Npc::getContainerStore (const MWWorld::Ptr& ptr) diff --git a/apps/openmw/mwclass/probe.cpp b/apps/openmw/mwclass/probe.cpp index 369f5efd6d..93ef46a67b 100644 --- a/apps/openmw/mwclass/probe.cpp +++ b/apps/openmw/mwclass/probe.cpp @@ -126,7 +126,7 @@ namespace MWClass std::unique_ptr Probe::use (const MWWorld::Ptr& ptr, bool force) const { - std::unique_ptr action(new MWWorld::ActionEquip(ptr, force)); + std::unique_ptr action = std::make_unique(ptr, force); action->setSound(getUpSoundId(ptr)); diff --git a/apps/openmw/mwclass/repair.cpp b/apps/openmw/mwclass/repair.cpp index c3a67a6086..748f2822f0 100644 --- a/apps/openmw/mwclass/repair.cpp +++ b/apps/openmw/mwclass/repair.cpp @@ -134,7 +134,7 @@ namespace MWClass std::unique_ptr Repair::use (const MWWorld::Ptr& ptr, bool force) const { - return std::unique_ptr(new MWWorld::ActionRepair(ptr, force)); + return std::make_unique(ptr, force); } bool Repair::canSell (const MWWorld::ConstPtr& item, int npcServices) const diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index 9fbc7a8da9..04aa2cb83d 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -301,7 +301,7 @@ namespace MWClass std::unique_ptr Weapon::use (const MWWorld::Ptr& ptr, bool force) const { - std::unique_ptr action(new MWWorld::ActionEquip(ptr, force)); + std::unique_ptr action = std::make_unique(ptr, force); action->setSound(getUpSoundId(ptr)); diff --git a/apps/openmw/mwgui/bookpage.cpp b/apps/openmw/mwgui/bookpage.cpp index 56ab2be8c2..0c84e0ce7a 100644 --- a/apps/openmw/mwgui/bookpage.cpp +++ b/apps/openmw/mwgui/bookpage.cpp @@ -1116,7 +1116,7 @@ public: if (j == this_->mActiveTextFormats.end ()) { - std::unique_ptr textFormat(new TextFormat (Font, this_)); + auto textFormat = std::make_unique(Font, this_); textFormat->mTexture = Font->getTextureFont (); diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index 680356b353..8279da089e 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -63,11 +63,11 @@ namespace MWGui , mGuiMode(GM_Inventory) , mLastXSize(0) , mLastYSize(0) - , mPreview(new MWRender::InventoryPreview(parent, resourceSystem, MWMechanics::getPlayer())) + , mPreview(std::make_unique(parent, resourceSystem, MWMechanics::getPlayer())) , mTrading(false) , mUpdateTimer(0.f) { - mPreviewTexture.reset(new osgMyGUI::OSGTexture(mPreview->getTexture(), mPreview->getTextureStateSet())); + mPreviewTexture = std::make_unique(mPreview->getTexture(), mPreview->getTextureStateSet()); mPreview->rebuild(); mMainWidget->castType()->eventWindowChangeCoord += MyGUI::newDelegate(this, &InventoryWindow::onWindowResize); diff --git a/apps/openmw/mwgui/loadingscreen.cpp b/apps/openmw/mwgui/loadingscreen.cpp index 1ea53a6ec7..61eca3d1d0 100644 --- a/apps/openmw/mwgui/loadingscreen.cpp +++ b/apps/openmw/mwgui/loadingscreen.cpp @@ -297,7 +297,7 @@ namespace MWGui if (!mGuiTexture.get()) { - mGuiTexture.reset(new osgMyGUI::OSGTexture(mTexture)); + mGuiTexture = std::make_unique(mTexture); } if (!mCopyFramebufferToTextureCallback) diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index dc1e47bf7d..1f24a66969 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -596,27 +596,27 @@ namespace MWGui osg::ref_ptr texture = mLocalMapRender->getMapTexture(entry.mCellX, entry.mCellY); if (texture) { - entry.mMapTexture.reset(new osgMyGUI::OSGTexture(texture)); + entry.mMapTexture = std::make_unique(texture); entry.mMapWidget->setRenderItemTexture(entry.mMapTexture.get()); entry.mMapWidget->getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 0.f, 1.f, 1.f)); needRedraw = true; } else - entry.mMapTexture.reset(new osgMyGUI::OSGTexture("", nullptr)); + entry.mMapTexture = std::make_unique(std::string(), nullptr); } if (!entry.mFogTexture && mFogOfWarToggled && mFogOfWarEnabled) { osg::ref_ptr tex = mLocalMapRender->getFogOfWarTexture(entry.mCellX, entry.mCellY); if (tex) { - entry.mFogTexture.reset(new osgMyGUI::OSGTexture(tex)); + entry.mFogTexture = std::make_unique(tex); entry.mFogWidget->setRenderItemTexture(entry.mFogTexture.get()); entry.mFogWidget->getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 1.f, 1.f, 0.f)); } else { entry.mFogWidget->setImageTexture("black"); - entry.mFogTexture.reset(new osgMyGUI::OSGTexture("", nullptr)); + entry.mFogTexture = std::make_unique(std::string(), nullptr); } needRedraw = true; } @@ -1279,11 +1279,11 @@ namespace MWGui { if (!mGlobalMapTexture.get()) { - mGlobalMapTexture.reset(new osgMyGUI::OSGTexture(mGlobalMapRender->getBaseTexture())); + mGlobalMapTexture = std::make_unique(mGlobalMapRender->getBaseTexture()); mGlobalMapImage->setRenderItemTexture(mGlobalMapTexture.get()); mGlobalMapImage->getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 0.f, 1.f, 1.f)); - mGlobalMapOverlayTexture.reset(new osgMyGUI::OSGTexture(mGlobalMapRender->getOverlayTexture())); + mGlobalMapOverlayTexture = std::make_unique(mGlobalMapRender->getOverlayTexture()); mGlobalMapOverlay->setRenderItemTexture(mGlobalMapOverlayTexture.get()); mGlobalMapOverlay->getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 0.f, 1.f, 1.f)); diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index efa4cea981..25679e4858 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -134,11 +134,11 @@ namespace MWGui mPreview.reset(nullptr); mPreviewTexture.reset(nullptr); - mPreview.reset(new MWRender::RaceSelectionPreview(mParent, mResourceSystem)); + mPreview = std::make_unique(mParent, mResourceSystem); mPreview->rebuild(); mPreview->setAngle (mCurrentAngle); - mPreviewTexture.reset(new osgMyGUI::OSGTexture(mPreview->getTexture(), mPreview->getTextureStateSet())); + mPreviewTexture = std::make_unique(mPreview->getTexture(), mPreview->getTextureStateSet()); mPreviewImage->setRenderItemTexture(mPreviewTexture.get()); mPreviewImage->getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 0.f, 1.f, 1.f)); diff --git a/apps/openmw/mwgui/savegamedialog.cpp b/apps/openmw/mwgui/savegamedialog.cpp index 086135d035..c17f229f6b 100644 --- a/apps/openmw/mwgui/savegamedialog.cpp +++ b/apps/openmw/mwgui/savegamedialog.cpp @@ -458,7 +458,7 @@ namespace MWGui texture->setResizeNonPowerOfTwoHint(false); texture->setUnRefImageDataAfterApply(true); - mScreenshotTexture.reset(new osgMyGUI::OSGTexture(texture)); + mScreenshotTexture = std::make_unique(texture); mScreenshot->setRenderItemTexture(mScreenshotTexture.get()); mScreenshot->getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 0.f, 1.f, 1.f)); diff --git a/apps/openmw/mwgui/videowidget.cpp b/apps/openmw/mwgui/videowidget.cpp index 36dd7fd3e2..a973db3a61 100644 --- a/apps/openmw/mwgui/videowidget.cpp +++ b/apps/openmw/mwgui/videowidget.cpp @@ -18,7 +18,7 @@ namespace MWGui VideoWidget::VideoWidget() : mVFS(nullptr) { - mPlayer.reset(new Video::VideoPlayer()); + mPlayer = std::make_unique(); setNeedKeyFocus(true); } @@ -50,7 +50,7 @@ void VideoWidget::playVideo(const std::string &video) if (!texture) return; - mTexture.reset(new osgMyGUI::OSGTexture(texture)); + mTexture = std::make_unique(texture); setRenderItemTexture(mTexture.get()); getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 1.f, 1.f, 0.f)); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 2a4855f4a3..a8043791bf 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -206,7 +206,7 @@ namespace MWGui MyGUI::LanguageManager::getInstance().eventRequestTag = MyGUI::newDelegate(this, &WindowManager::onRetrieveTag); // Load fonts - mFontLoader.reset(new Gui::FontLoader(encoding, resourceSystem->getVFS(), userDataPath, mScalingFactor)); + mFontLoader = std::make_unique(encoding, resourceSystem->getVFS(), userDataPath, mScalingFactor); mFontLoader->loadBitmapFonts(exportFonts); //Register own widgets with MyGUI @@ -238,7 +238,7 @@ namespace MWGui WindowManager::loadUserFonts(); bool keyboardNav = Settings::Manager::getBool("keyboard navigation", "GUI"); - mKeyboardNavigation.reset(new KeyboardNavigation()); + mKeyboardNavigation = std::make_unique(); mKeyboardNavigation->setEnabled(keyboardNav); Gui::ImageButton::setDefaultNeedKeyFocus(keyboardNav); @@ -288,7 +288,7 @@ namespace MWGui if (useShaders) mGuiPlatform->getRenderManagerPtr()->enableShaders(mResourceSystem->getSceneManager()->getShaderManager()); - mStatsWatcher.reset(new StatsWatcher()); + mStatsWatcher = std::make_unique(); } void WindowManager::loadUserFonts() diff --git a/apps/openmw/mwmechanics/aiactivate.cpp b/apps/openmw/mwmechanics/aiactivate.cpp index c2bcab2297..21287af1f6 100644 --- a/apps/openmw/mwmechanics/aiactivate.cpp +++ b/apps/openmw/mwmechanics/aiactivate.cpp @@ -46,7 +46,7 @@ namespace MWMechanics void AiActivate::writeState(ESM::AiSequence::AiSequence &sequence) const { - std::unique_ptr activate(new ESM::AiSequence::AiActivate()); + auto activate = std::make_unique(); activate->mTargetId = mObjectId; activate->mRepeat = getRepeat(); diff --git a/apps/openmw/mwmechanics/aicombat.cpp b/apps/openmw/mwmechanics/aicombat.cpp index bd6bd385e8..a3e7cb6a26 100644 --- a/apps/openmw/mwmechanics/aicombat.cpp +++ b/apps/openmw/mwmechanics/aicombat.cpp @@ -200,7 +200,7 @@ namespace MWMechanics } else { - currentAction.reset(new ActionFlee()); + currentAction = std::make_unique(); actionCooldown = currentAction->getActionCooldown(); } @@ -300,7 +300,7 @@ namespace MWMechanics storage.mUseCustomDestination = false; storage.stopAttack(); actor.getClass().getCreatureStats(actor).setAttackingOrSpell(false); - currentAction.reset(new ActionFlee()); + currentAction = std::make_unique(); actionCooldown = currentAction->getActionCooldown(); storage.startFleeing(); MWBase::Environment::get().getDialogueManager()->say(actor, "flee"); @@ -460,7 +460,7 @@ namespace MWMechanics void AiCombat::writeState(ESM::AiSequence::AiSequence &sequence) const { - std::unique_ptr combat(new ESM::AiSequence::AiCombat()); + auto combat = std::make_unique(); combat->mTargetActorId = mTargetActorId; ESM::AiSequence::AiPackageContainer package; diff --git a/apps/openmw/mwmechanics/aicombataction.cpp b/apps/openmw/mwmechanics/aicombataction.cpp index 30573c131e..3b3ff1da89 100644 --- a/apps/openmw/mwmechanics/aicombataction.cpp +++ b/apps/openmw/mwmechanics/aicombataction.cpp @@ -148,7 +148,7 @@ namespace MWMechanics float bestActionRating = 0.f; float antiFleeRating = 0.f; // Default to hand-to-hand combat - std::unique_ptr bestAction (new ActionWeapon(MWWorld::Ptr())); + std::unique_ptr bestAction = std::make_unique(MWWorld::Ptr()); if (actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) { bestAction->prepare(actor); @@ -165,7 +165,7 @@ namespace MWMechanics if (rating > bestActionRating) { bestActionRating = rating; - bestAction.reset(new ActionPotion(*it)); + bestAction = std::make_unique(*it); antiFleeRating = std::numeric_limits::max(); } } @@ -176,7 +176,7 @@ namespace MWMechanics if (rating > bestActionRating) { bestActionRating = rating; - bestAction.reset(new ActionEnchantedItem(it)); + bestAction = std::make_unique(it); antiFleeRating = std::numeric_limits::max(); } } @@ -202,7 +202,7 @@ namespace MWMechanics ammo = bestBolt; bestActionRating = rating; - bestAction.reset(new ActionWeapon(*it, ammo)); + bestAction = std::make_unique(*it, ammo); antiFleeRating = vanillaRateWeaponAndAmmo(*it, ammo, actor, enemy); } } @@ -214,13 +214,13 @@ namespace MWMechanics if (rating > bestActionRating) { bestActionRating = rating; - bestAction.reset(new ActionSpell(spell->mId)); + bestAction = std::make_unique(spell->mId); antiFleeRating = vanillaRateSpell(spell, actor, enemy); } } if (makeFleeDecision(actor, enemy, antiFleeRating)) - bestAction.reset(new ActionFlee()); + bestAction = std::make_unique(); if (bestAction.get()) bestAction->prepare(actor); diff --git a/apps/openmw/mwmechanics/aiescort.cpp b/apps/openmw/mwmechanics/aiescort.cpp index 2e7d55712f..aa58dacd8f 100644 --- a/apps/openmw/mwmechanics/aiescort.cpp +++ b/apps/openmw/mwmechanics/aiescort.cpp @@ -96,7 +96,7 @@ namespace MWMechanics void AiEscort::writeState(ESM::AiSequence::AiSequence &sequence) const { - std::unique_ptr escort(new ESM::AiSequence::AiEscort()); + auto escort = std::make_unique(); escort->mData.mX = mX; escort->mData.mY = mY; escort->mData.mZ = mZ; diff --git a/apps/openmw/mwmechanics/aifollow.cpp b/apps/openmw/mwmechanics/aifollow.cpp index 9444303821..f1ced856f0 100644 --- a/apps/openmw/mwmechanics/aifollow.cpp +++ b/apps/openmw/mwmechanics/aifollow.cpp @@ -201,7 +201,7 @@ bool AiFollow::isCommanded() const void AiFollow::writeState(ESM::AiSequence::AiSequence &sequence) const { - std::unique_ptr follow(new ESM::AiSequence::AiFollow()); + auto follow = std::make_unique(); follow->mData.mX = mX; follow->mData.mY = mY; follow->mData.mZ = mZ; diff --git a/apps/openmw/mwmechanics/aipursue.cpp b/apps/openmw/mwmechanics/aipursue.cpp index 25dd08436b..e5e1b0297c 100644 --- a/apps/openmw/mwmechanics/aipursue.cpp +++ b/apps/openmw/mwmechanics/aipursue.cpp @@ -84,7 +84,7 @@ MWWorld::Ptr AiPursue::getTarget() const void AiPursue::writeState(ESM::AiSequence::AiSequence &sequence) const { - std::unique_ptr pursue(new ESM::AiSequence::AiPursue()); + auto pursue = std::make_unique(); pursue->mTargetActorId = mTargetActorId; ESM::AiSequence::AiPackageContainer package; diff --git a/apps/openmw/mwmechanics/aisequence.cpp b/apps/openmw/mwmechanics/aisequence.cpp index f138d8dc97..fc91ce0c42 100644 --- a/apps/openmw/mwmechanics/aisequence.cpp +++ b/apps/openmw/mwmechanics/aisequence.cpp @@ -498,41 +498,41 @@ void AiSequence::readState(const ESM::AiSequence::AiSequence &sequence) { case ESM::AiSequence::Ai_Wander: { - package.reset(new AiWander(&static_cast(*container.mPackage))); + package = std::make_unique(&static_cast(*container.mPackage)); break; } case ESM::AiSequence::Ai_Travel: { const ESM::AiSequence::AiTravel& source = static_cast(*container.mPackage); if (source.mHidden) - package.reset(new AiInternalTravel(&source)); + package = std::make_unique(&source); else - package.reset(new AiTravel(&source)); + package = std::make_unique(&source); break; } case ESM::AiSequence::Ai_Escort: { - package.reset(new AiEscort(&static_cast(*container.mPackage))); + package = std::make_unique(&static_cast(*container.mPackage)); break; } case ESM::AiSequence::Ai_Follow: { - package.reset(new AiFollow(&static_cast(*container.mPackage))); + package = std::make_unique(&static_cast(*container.mPackage)); break; } case ESM::AiSequence::Ai_Activate: { - package.reset(new AiActivate(&static_cast(*container.mPackage))); + package = std::make_unique(&static_cast(*container.mPackage)); break; } case ESM::AiSequence::Ai_Combat: { - package.reset(new AiCombat(&static_cast(*container.mPackage))); + package = std::make_unique(&static_cast(*container.mPackage)); break; } case ESM::AiSequence::Ai_Pursue: { - package.reset(new AiPursue(&static_cast(*container.mPackage))); + package = std::make_unique(&static_cast(*container.mPackage)); break; } default: diff --git a/apps/openmw/mwmechanics/aitravel.cpp b/apps/openmw/mwmechanics/aitravel.cpp index 770d2f7ba6..5d453c4b44 100644 --- a/apps/openmw/mwmechanics/aitravel.cpp +++ b/apps/openmw/mwmechanics/aitravel.cpp @@ -123,7 +123,7 @@ namespace MWMechanics void AiTravel::writeState(ESM::AiSequence::AiSequence &sequence) const { - std::unique_ptr travel(new ESM::AiSequence::AiTravel()); + auto travel = std::make_unique(); travel->mData.mX = mX; travel->mData.mY = mY; travel->mData.mZ = mZ; diff --git a/apps/openmw/mwmechanics/aiwander.cpp b/apps/openmw/mwmechanics/aiwander.cpp index a4da1ebd68..d7f2026b82 100644 --- a/apps/openmw/mwmechanics/aiwander.cpp +++ b/apps/openmw/mwmechanics/aiwander.cpp @@ -899,7 +899,7 @@ namespace MWMechanics else remainingDuration = mDuration; - std::unique_ptr wander(new ESM::AiSequence::AiWander()); + auto wander = std::make_unique(); wander->mData.mDistance = mDistance; wander->mData.mDuration = mDuration; wander->mData.mTimeOfDay = mTimeOfDay; diff --git a/apps/openmw/mwphysics/actor.cpp b/apps/openmw/mwphysics/actor.cpp index a1f5a48388..bfaa15edfe 100644 --- a/apps/openmw/mwphysics/actor.cpp +++ b/apps/openmw/mwphysics/actor.cpp @@ -55,7 +55,7 @@ Actor::Actor(const MWWorld::Ptr& ptr, const Resource::BulletShape* shape, Physic Log(Debug::Error) << "Error: Failed to calculate bounding box for actor \"" << ptr.getCellRef().getRefId() << "\"."; } - mShape.reset(new btBoxShape(Misc::Convert::toBullet(mOriginalHalfExtents))); + mShape = std::make_unique(Misc::Convert::toBullet(mOriginalHalfExtents)); mRotationallyInvariant = (mMeshTranslation.x() == 0.0 && mMeshTranslation.y() == 0.0) && std::fabs(mOriginalHalfExtents.x() - mOriginalHalfExtents.y()) < 2.2; mConvexShape = static_cast(mShape.get()); diff --git a/apps/openmw/mwphysics/physicssystem.cpp b/apps/openmw/mwphysics/physicssystem.cpp index 4de60f4900..05c7a37262 100644 --- a/apps/openmw/mwphysics/physicssystem.cpp +++ b/apps/openmw/mwphysics/physicssystem.cpp @@ -98,7 +98,7 @@ namespace namespace MWPhysics { PhysicsSystem::PhysicsSystem(Resource::ResourceSystem* resourceSystem, osg::ref_ptr parentNode) - : mShapeManager(new Resource::BulletShapeManager(resourceSystem->getVFS(), resourceSystem->getSceneManager(), resourceSystem->getNifFileManager())) + : mShapeManager(std::make_unique(resourceSystem->getVFS(), resourceSystem->getSceneManager(), resourceSystem->getNifFileManager())) , mResourceSystem(resourceSystem) , mDebugDrawEnabled(false) , mTimeAccum(0.0f) @@ -891,8 +891,8 @@ namespace MWPhysics return; } - mWaterCollisionObject.reset(new btCollisionObject()); - mWaterCollisionShape.reset(new btStaticPlaneShape(btVector3(0,0,1), mWaterHeight)); + mWaterCollisionObject = std::make_unique(); + mWaterCollisionShape = std::make_unique(btVector3(0,0,1), mWaterHeight); mWaterCollisionObject->setCollisionShape(mWaterCollisionShape.get()); mTaskScheduler->addCollisionObject(mWaterCollisionObject.get(), CollisionType_Water, CollisionType_Actor|CollisionType_Projectile); diff --git a/apps/openmw/mwrender/creatureanimation.cpp b/apps/openmw/mwrender/creatureanimation.cpp index f3a92bff46..174ea036e1 100644 --- a/apps/openmw/mwrender/creatureanimation.cpp +++ b/apps/openmw/mwrender/creatureanimation.cpp @@ -147,7 +147,7 @@ void CreatureWeaponAnimation::updatePart(PartHolderPtr& scene, int slot) { osg::ref_ptr attached = attach(itemModel, bonename, bonename, item.getType() == ESM::Light::sRecordId); - scene.reset(new PartHolder(attached)); + scene = std::make_unique(attached); if (!item.getClass().getEnchantment(item).empty()) mGlowUpdater = SceneUtil::addEnchantedGlow(attached, mResourceSystem, item.getClass().getEnchantmentColor(item)); @@ -173,7 +173,7 @@ void CreatureWeaponAnimation::updatePart(PartHolderPtr& scene, int slot) if (slot == MWWorld::InventoryStore::Slot_CarriedRight) source = mWeaponAnimationTime; else - source.reset(new NullAnimationTime); + source = std::make_shared(); SceneUtil::AssignControllerSourcesVisitor assignVisitor(source); attached->accept(assignVisitor); diff --git a/apps/openmw/mwrender/localmap.cpp b/apps/openmw/mwrender/localmap.cpp index fda98a1589..9e7b95fb0c 100644 --- a/apps/openmw/mwrender/localmap.cpp +++ b/apps/openmw/mwrender/localmap.cpp @@ -122,7 +122,7 @@ void LocalMap::saveFogOfWar(MWWorld::CellStore* cell) if (segment.mFogOfWarImage && segment.mHasFogState) { - std::unique_ptr fog (new ESM::FogState()); + auto fog = std::make_unique(); fog->mFogTextures.emplace_back(); segment.saveFogOfWar(fog->mFogTextures.back()); @@ -134,7 +134,7 @@ void LocalMap::saveFogOfWar(MWWorld::CellStore* cell) { auto segments = divideIntoSegments(mBounds, mMapWorldSize); - std::unique_ptr fog (new ESM::FogState()); + auto fog = std::make_unique(); fog->mBounds.mMinX = mBounds.xMin(); fog->mBounds.mMaxX = mBounds.xMax(); diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index e0869a45dd..5292886754 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -401,7 +401,7 @@ namespace MWRender if (Settings::Manager::getBool("terrain shadows", "Shadows")) shadowCastingTraversalMask |= Mask_Terrain; - mShadowManager.reset(new SceneUtil::ShadowManager(sceneRoot, mRootNode, shadowCastingTraversalMask, indoorShadowCastingTraversalMask, Mask_Terrain|Mask_Object|Mask_Static, mResourceSystem->getSceneManager()->getShaderManager())); + mShadowManager = std::make_unique(sceneRoot, mRootNode, shadowCastingTraversalMask, indoorShadowCastingTraversalMask, Mask_Terrain|Mask_Object|Mask_Static, mResourceSystem->getSceneManager()->getShaderManager()); Shader::ShaderManager::DefineMap shadowDefines = mShadowManager->getShadowDefines(); Shader::ShaderManager::DefineMap lightDefines = sceneRoot->getLightDefines(); @@ -435,13 +435,13 @@ namespace MWRender // It is unnecessary to stop/start the viewer as no frames are being rendered yet. mResourceSystem->getSceneManager()->getShaderManager().setGlobalDefines(globalDefines); - mNavMesh.reset(new NavMesh(mRootNode, mWorkQueue, Settings::Manager::getBool("enable nav mesh render", "Navigator"), - parseNavMeshMode(Settings::Manager::getString("nav mesh render mode", "Navigator")))); - mActorsPaths.reset(new ActorsPaths(mRootNode, Settings::Manager::getBool("enable agents paths render", "Navigator"))); - mRecastMesh.reset(new RecastMesh(mRootNode, Settings::Manager::getBool("enable recast mesh render", "Navigator"))); - mPathgrid.reset(new Pathgrid(mRootNode)); + mNavMesh = std::make_unique(mRootNode, mWorkQueue, Settings::Manager::getBool("enable nav mesh render", "Navigator"), + parseNavMeshMode(Settings::Manager::getString("nav mesh render mode", "Navigator"))); + mActorsPaths = std::make_unique(mRootNode, Settings::Manager::getBool("enable agents paths render", "Navigator")); + mRecastMesh = std::make_unique(mRootNode, Settings::Manager::getBool("enable recast mesh render", "Navigator")); + mPathgrid = std::make_unique(mRootNode); - mObjects.reset(new Objects(mResourceSystem, sceneRoot)); + mObjects = std::make_unique(mResourceSystem, sceneRoot); if (getenv("OPENMW_DONT_PRECOMPILE") == nullptr) { @@ -451,7 +451,7 @@ namespace MWRender mResourceSystem->getSceneManager()->setIncrementalCompileOperation(mViewer->getIncrementalCompileOperation()); - mEffectManager.reset(new EffectManager(sceneRoot, mResourceSystem)); + mEffectManager = std::make_unique(sceneRoot, mResourceSystem); const std::string normalMapPattern = Settings::Manager::getString("normal map pattern", "Shaders"); const std::string heightMapPattern = Settings::Manager::getString("normal height map pattern", "Shaders"); @@ -459,7 +459,7 @@ namespace MWRender const bool useTerrainNormalMaps = Settings::Manager::getBool("auto use terrain normal maps", "Shaders"); const bool useTerrainSpecularMaps = Settings::Manager::getBool("auto use terrain specular maps", "Shaders"); - mTerrainStorage.reset(new TerrainStorage(mResourceSystem, normalMapPattern, heightMapPattern, useTerrainNormalMaps, specularMapPattern, useTerrainSpecularMaps)); + mTerrainStorage = std::make_unique(mResourceSystem, normalMapPattern, heightMapPattern, useTerrainNormalMaps, specularMapPattern, useTerrainSpecularMaps); const float lodFactor = Settings::Manager::getFloat("lod factor", "Terrain"); bool groundcover = Settings::Manager::getBool("enabled", "Groundcover"); @@ -474,18 +474,18 @@ namespace MWRender float maxCompGeometrySize = Settings::Manager::getFloat("max composite geometry size", "Terrain"); maxCompGeometrySize = std::max(maxCompGeometrySize, 1.f); bool debugChunks = Settings::Manager::getBool("debug chunks", "Terrain"); - mTerrain.reset(new Terrain::QuadTreeWorld( + mTerrain = std::make_unique( sceneRoot, mRootNode, mResourceSystem, mTerrainStorage.get(), Mask_Terrain, Mask_PreCompile, Mask_Debug, - compMapResolution, compMapLevel, lodFactor, vertexLodMod, maxCompGeometrySize, debugChunks)); + compMapResolution, compMapLevel, lodFactor, vertexLodMod, maxCompGeometrySize, debugChunks); if (Settings::Manager::getBool("object paging", "Terrain")) { - mObjectPaging.reset(new ObjectPaging(mResourceSystem->getSceneManager())); + mObjectPaging = std::make_unique(mResourceSystem->getSceneManager()); static_cast(mTerrain.get())->addChunkManager(mObjectPaging.get()); mResourceSystem->addResourceManager(mObjectPaging.get()); } } else - mTerrain.reset(new Terrain::TerrainGrid(sceneRoot, mRootNode, mResourceSystem, mTerrainStorage.get(), Mask_Terrain, Mask_PreCompile, Mask_Debug)); + mTerrain = std::make_unique(sceneRoot, mRootNode, mResourceSystem, mTerrainStorage.get(), Mask_Terrain, Mask_PreCompile, Mask_Debug); mTerrain->setTargetFrameRate(Settings::Manager::getFloat("target framerate", "Cells")); @@ -494,7 +494,7 @@ namespace MWRender float density = Settings::Manager::getFloat("density", "Groundcover"); density = std::clamp(density, 0.f, 1.f); - mGroundcover.reset(new Groundcover(mResourceSystem->getSceneManager(), density, groundcoverDistance, groundcoverStore)); + mGroundcover = std::make_unique(mResourceSystem->getSceneManager(), density, groundcoverDistance, groundcoverStore); static_cast(mTerrain.get())->addChunkManager(mGroundcover.get()); mResourceSystem->addResourceManager(mGroundcover.get()); } @@ -513,11 +513,11 @@ namespace MWRender resourceSystem->getSceneManager()->setSupportsNormalsRT(mPostProcessor->getSupportsNormalsRT()); // water goes after terrain for correct waterculling order - mWater.reset(new Water(sceneRoot->getParent(0), sceneRoot, mResourceSystem, mViewer->getIncrementalCompileOperation(), resourcePath)); + mWater = std::make_unique(sceneRoot->getParent(0), sceneRoot, mResourceSystem, mViewer->getIncrementalCompileOperation(), resourcePath); - mCamera.reset(new Camera(mViewer->getCamera())); + mCamera = std::make_unique(mViewer->getCamera()); - mScreenshotManager.reset(new ScreenshotManager(viewer, mRootNode, sceneRoot, mResourceSystem, mWater.get())); + mScreenshotManager = std::make_unique(viewer, mRootNode, sceneRoot, mResourceSystem, mWater.get()); mViewer->setLightingMode(osgViewer::View::NO_LIGHT); @@ -544,9 +544,9 @@ namespace MWRender sceneRoot->getOrCreateStateSet()->addUniform(new osg::Uniform("emissiveMult", 1.f)); sceneRoot->getOrCreateStateSet()->addUniform(new osg::Uniform("specStrength", 1.f)); - mFog.reset(new FogManager()); + mFog = std::make_unique(); - mSky.reset(new SkyManager(sceneRoot, resourceSystem->getSceneManager())); + mSky = std::make_unique(sceneRoot, resourceSystem->getSceneManager()); mSky->setCamera(mViewer->getCamera()); source->setStateSetModes(*mRootNode->getOrCreateStateSet(), osg::StateAttribute::ON); diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index d8add9a685..754810fc8c 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -303,10 +303,10 @@ namespace MWRender mAtmosphereNightUpdater = new AtmosphereNightUpdater(mSceneManager->getImageManager(), forceShaders); atmosphereNight->addUpdateCallback(mAtmosphereNightUpdater); - mSun.reset(new Sun(mEarlyRenderBinRoot, *mSceneManager)); + mSun = std::make_unique(mEarlyRenderBinRoot, *mSceneManager); mSun->setSunglare(mSunglareEnabled); - mMasser.reset(new Moon(mEarlyRenderBinRoot, *mSceneManager, Fallback::Map::getFloat("Moons_Masser_Size")/125, Moon::Type_Masser)); - mSecunda.reset(new Moon(mEarlyRenderBinRoot, *mSceneManager, Fallback::Map::getFloat("Moons_Secunda_Size")/125, Moon::Type_Secunda)); + mMasser = std::make_unique(mEarlyRenderBinRoot, *mSceneManager, Fallback::Map::getFloat("Moons_Masser_Size")/125, Moon::Type_Masser); + mSecunda = std::make_unique(mEarlyRenderBinRoot, *mSceneManager, Fallback::Map::getFloat("Moons_Secunda_Size")/125, Moon::Type_Secunda); mCloudNode = new osg::Group; mEarlyRenderBinRoot->addChild(mCloudNode); diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index 822eab04fe..41fbc1c05b 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -456,7 +456,7 @@ Water::Water(osg::Group *parent, osg::Group* sceneRoot, Resource::ResourceSystem , mCullCallback(nullptr) , mShaderWaterStateSetUpdater(nullptr) { - mSimulation.reset(new RippleSimulation(mSceneRoot, resourceSystem)); + mSimulation = std::make_unique(mSceneRoot, resourceSystem); mWaterGeom = SceneUtil::createWaterGeometry(Constants::CellSizeInUnits*150, 40, 900); mWaterGeom->setDrawCallback(new DepthClampCallback); diff --git a/apps/openmw/mwsound/movieaudiofactory.cpp b/apps/openmw/mwsound/movieaudiofactory.cpp index e5bda0ad02..aef8f7fe93 100644 --- a/apps/openmw/mwsound/movieaudiofactory.cpp +++ b/apps/openmw/mwsound/movieaudiofactory.cpp @@ -155,7 +155,7 @@ namespace MWSound std::unique_ptr MovieAudioFactory::createDecoder(Video::VideoState* videoState) { - std::unique_ptr decoder(new MWSound::MovieAudioDecoder(videoState)); + auto decoder = std::make_unique(videoState); decoder->setupFormat(); MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager(); diff --git a/apps/openmw/mwsound/openal_output.cpp b/apps/openmw/mwsound/openal_output.cpp index 649c67961d..3fe220019d 100644 --- a/apps/openmw/mwsound/openal_output.cpp +++ b/apps/openmw/mwsound/openal_output.cpp @@ -428,7 +428,7 @@ bool OpenAL_SoundStream::init(bool getLoudnessData) mBufferSize *= mFrameSize; if (getLoudnessData) - mLoudnessAnalyzer.reset(new Sound_Loudness(sLoudnessFPS, mSampleRate, chans, type)); + mLoudnessAnalyzer = std::make_unique(sLoudnessFPS, mSampleRate, chans, type); mIsFinished = false; return true; @@ -1501,7 +1501,7 @@ OpenAL_Output::OpenAL_Output(SoundManager &mgr) , mDevice(nullptr), mContext(nullptr) , mListenerPos(0.0f, 0.0f, 0.0f), mListenerEnv(Env_Normal) , mWaterFilter(0), mWaterEffect(0), mDefaultEffect(0), mEffectSlot(0) - , mStreamThread(new StreamThread) + , mStreamThread(std::make_unique()) { } diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index 0c7cc631b7..44dcc0de15 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -792,7 +792,7 @@ namespace MWWorld void CellStore::readFog(ESM::ESMReader &reader) { - mFogState.reset(new ESM::FogState()); + mFogState = std::make_unique(); mFogState->load(reader); } diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index 9dc8ba5631..f8a9164fa2 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -117,12 +117,12 @@ namespace MWWorld std::unique_ptr Class::activate (const Ptr& ptr, const Ptr& actor) const { - return std::unique_ptr (new NullAction); + return std::make_unique(); } std::unique_ptr Class::use (const Ptr& ptr, bool force) const { - return std::unique_ptr (new NullAction); + return std::make_unique(); } ContainerStore& Class::getContainerStore (const Ptr& ptr) const @@ -332,7 +332,7 @@ namespace MWWorld std::unique_ptr Class::defaultItemActivate(const Ptr &ptr, const Ptr &actor) const { if(!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory)) - return std::unique_ptr(new NullAction()); + return std::make_unique(); if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) { @@ -340,13 +340,13 @@ namespace MWWorld auto& prng = MWBase::Environment::get().getWorld()->getPrng(); const ESM::Sound *sound = store.get().searchRandom("WolfItem", prng); - std::unique_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); + std::unique_ptr action = std::make_unique("#{sWerewolfRefusal}"); if(sound) action->setSound(sound->mId); return action; } - std::unique_ptr action(new ActionTake(ptr)); + std::unique_ptr action = std::make_unique(ptr); action->setSound(getUpSoundId(ptr)); return action; diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index c362cddd38..9cd0c2e4e4 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -772,7 +772,7 @@ namespace MWWorld , mPreloadFastTravel(Settings::Manager::getBool("preload fast travel", "Cells")) , mPredictionTime(Settings::Manager::getFloat("prediction time", "Cells")) { - mPreloader.reset(new CellPreloader(rendering.getResourceSystem(), physics->getShapeManager(), rendering.getTerrain(), rendering.getLandManager())); + mPreloader = std::make_unique(rendering.getResourceSystem(), physics->getShapeManager(), rendering.getTerrain(), rendering.getLandManager()); mPreloader->setWorkQueue(mRendering.getWorkQueue()); rendering.getResourceSystem()->setExpiryDelay(Settings::Manager::getFloat("cache expiry delay", "Cells")); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 333ced2116..15034b9b12 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -175,7 +175,7 @@ namespace MWWorld break; } - mCurrentDate.reset(new DateTimeManager()); + mCurrentDate = std::make_unique(); fillGlobalVariables(); @@ -184,7 +184,7 @@ namespace MWWorld mSwimHeightScale = mStore.get().find("fSwimHeightScale")->mValue.getFloat(); - mPhysics.reset(new MWPhysics::PhysicsSystem(resourceSystem, rootNode)); + mPhysics = std::make_unique(resourceSystem, rootNode); if (Settings::Manager::getBool("enable", "Navigator")) { @@ -197,13 +197,13 @@ namespace MWWorld mNavigator = DetourNavigator::makeNavigatorStub(); } - mRendering.reset(new MWRender::RenderingManager(viewer, rootNode, resourceSystem, workQueue, resourcePath, *mNavigator, mGroundcoverStore)); - mProjectileManager.reset(new ProjectileManager(mRendering->getLightRoot()->asGroup(), resourceSystem, mRendering.get(), mPhysics.get())); + mRendering = std::make_unique(viewer, rootNode, resourceSystem, workQueue, resourcePath, *mNavigator, mGroundcoverStore); + mProjectileManager = std::make_unique(mRendering->getLightRoot()->asGroup(), resourceSystem, mRendering.get(), mPhysics.get()); mRendering->preloadCommonAssets(); - mWeatherManager.reset(new MWWorld::WeatherManager(*mRendering, mStore)); + mWeatherManager = std::make_unique(*mRendering, mStore); - mWorldScene.reset(new Scene(*this, *mRendering.get(), mPhysics.get(), *mNavigator)); + mWorldScene = std::make_unique(*this, *mRendering.get(), mPhysics.get(), *mNavigator); } void World::fillGlobalVariables() @@ -231,7 +231,7 @@ namespace MWWorld // we don't want old weather to persist on a new game // Note that if reset later, the initial ChangeWeather that the chargen script calls will be lost. mWeatherManager.reset(); - mWeatherManager.reset(new MWWorld::WeatherManager(*mRendering.get(), mStore)); + mWeatherManager = std::make_unique(*mRendering.get(), mStore); if (!bypass) { @@ -2443,7 +2443,7 @@ namespace MWWorld { const ESM::NPC *player = mStore.get().find("player"); if (!mPlayer) - mPlayer.reset(new MWWorld::Player(player)); + mPlayer = std::make_unique(player); else { // Remove the old CharacterController From db1a372e5b576b099f58eee4bfde903944999390 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Sun, 29 May 2022 13:25:17 +0200 Subject: [PATCH 3/4] Replace new with make_unique in opencs --- apps/opencs/model/doc/document.cpp | 6 ++--- apps/opencs/model/filter/parser.cpp | 2 +- apps/opencs/model/world/actoradapter.cpp | 4 ++-- apps/opencs/model/world/collection.hpp | 15 ++++++------ apps/opencs/model/world/commanddispatcher.cpp | 5 ++-- apps/opencs/model/world/data.cpp | 12 +++++----- apps/opencs/model/world/idcollection.cpp | 2 +- apps/opencs/model/world/idcollection.hpp | 10 ++++---- apps/opencs/model/world/infocollection.cpp | 10 ++++---- .../opencs/model/world/nestedidcollection.hpp | 8 +++---- .../model/world/nestedinfocollection.cpp | 8 +++---- apps/opencs/model/world/refcollection.cpp | 22 +++++++++--------- apps/opencs/model/world/refiddata.hpp | 2 +- apps/opencs/view/render/cell.cpp | 16 ++++++------- apps/opencs/view/render/object.cpp | 2 +- .../view/render/pagedworldspacewidget.cpp | 8 +++---- apps/opencs/view/render/terrainshapemode.cpp | 23 +++++++++---------- .../opencs/view/render/terraintexturemode.cpp | 7 +++--- .../view/render/unpagedworldspacewidget.cpp | 4 ++-- apps/opencs/view/world/creator.hpp | 2 +- apps/opencs/view/world/dialoguesubview.cpp | 2 +- apps/opencs/view/world/genericcreator.cpp | 8 +++---- 22 files changed, 86 insertions(+), 92 deletions(-) diff --git a/apps/opencs/model/doc/document.cpp b/apps/opencs/model/doc/document.cpp index f4071c525d..0b7b73693c 100644 --- a/apps/opencs/model/doc/document.cpp +++ b/apps/opencs/model/doc/document.cpp @@ -116,7 +116,7 @@ void CSMDoc::Document::addOptionalGmst (const ESM::GameSetting& gmst) { if (getData().getGmsts().searchId (gmst.mId)==-1) { - std::unique_ptr > record(new CSMWorld::Record); + auto record = std::make_unique>(); record->mBase = gmst; record->mState = CSMWorld::RecordBase::State_BaseOnly; getData().getGmsts().appendRecord (std::move(record)); @@ -127,7 +127,7 @@ void CSMDoc::Document::addOptionalGlobal (const ESM::Global& global) { if (getData().getGlobals().searchId (global.mId)==-1) { - std::unique_ptr > record(new CSMWorld::Record); + auto record = std::make_unique>(); record->mBase = global; record->mState = CSMWorld::RecordBase::State_BaseOnly; getData().getGlobals().appendRecord (std::move(record)); @@ -138,7 +138,7 @@ void CSMDoc::Document::addOptionalMagicEffect (const ESM::MagicEffect& magicEffe { if (getData().getMagicEffects().searchId (magicEffect.mId)==-1) { - std::unique_ptr > record(new CSMWorld::Record); + auto record = std::make_unique>(); record->mBase = magicEffect; record->mState = CSMWorld::RecordBase::State_BaseOnly; getData().getMagicEffects().appendRecord (std::move(record)); diff --git a/apps/opencs/model/filter/parser.cpp b/apps/opencs/model/filter/parser.cpp index c69a54726d..d02205d596 100644 --- a/apps/opencs/model/filter/parser.cpp +++ b/apps/opencs/model/filter/parser.cpp @@ -579,7 +579,7 @@ bool CSMFilter::Parser::parse (const std::string& filter, bool allowPredefined) else { // Empty filter string equals to filter "true". - mFilter.reset (new BooleanNode (true)); + mFilter = std::make_shared(true); } return true; diff --git a/apps/opencs/model/world/actoradapter.cpp b/apps/opencs/model/world/actoradapter.cpp index bc8f519dcd..e6a193b3e0 100644 --- a/apps/opencs/model/world/actoradapter.cpp +++ b/apps/opencs/model/world/actoradapter.cpp @@ -228,7 +228,7 @@ namespace CSMWorld } // Create the actor data - data.reset(new ActorData()); + data = std::make_shared(); setupActor(id, data); mCachedActors.insert(id, data); return data; @@ -431,7 +431,7 @@ namespace CSMWorld if (data) return data; // Create the race data - data.reset(new RaceData()); + data = std::make_shared(); setupRace(id, data); mCachedRaces.insert(id, data); return data; diff --git a/apps/opencs/model/world/collection.hpp b/apps/opencs/model/world/collection.hpp index d15a4ff54d..25e350f3a3 100644 --- a/apps/opencs/model/world/collection.hpp +++ b/apps/opencs/model/world/collection.hpp @@ -249,12 +249,13 @@ namespace CSMWorld int Collection::cloneRecordImp(const std::string& origin, const std::string& destination, UniversalId::Type type) { - std::unique_ptr > copy(new Record); - copy->mModified = getRecord(origin).get(); - copy->mState = RecordBase::State_ModifiedOnly; - IdAccessorT().setId(copy->get(), destination); + auto copy = std::make_unique>(); + copy->mModified = getRecord(origin).get(); + copy->mState = RecordBase::State_ModifiedOnly; + IdAccessorT().setId(copy->get(), destination); - if (type == UniversalId::Type_Reference) { + if (type == UniversalId::Type_Reference) + { CSMWorld::CellRef* ptr = (CSMWorld::CellRef*) ©->mModified; ptr->mRefNum.mIndex = 0; } @@ -338,7 +339,7 @@ namespace CSMWorld if (iter==mIndex.end()) { - std::unique_ptr > record2(new Record); + auto record2 = std::make_unique>(); record2->mState = Record::State_ModifiedOnly; record2->mModified = record; @@ -469,7 +470,7 @@ namespace CSMWorld IdAccessorT().setId(record, id); record.blank(); - std::unique_ptr > record2(new Record); + auto record2 = std::make_unique>(); record2->mState = Record::State_ModifiedOnly; record2->mModified = record; diff --git a/apps/opencs/model/world/commanddispatcher.cpp b/apps/opencs/model/world/commanddispatcher.cpp index c5d78b6586..dc815f43f3 100644 --- a/apps/opencs/model/world/commanddispatcher.cpp +++ b/apps/opencs/model/world/commanddispatcher.cpp @@ -170,14 +170,13 @@ void CSMWorld::CommandDispatcher::executeModify (QAbstractItemModel *model, cons if (cellId.find ('#')!=std::string::npos) { // Need to recalculate the cell - modifyCell.reset (new UpdateCellCommand (model2, row)); + modifyCell = std::make_unique(model2, row); } } } } - std::unique_ptr modifyData ( - new CSMWorld::ModifyCommand (*model, index, new_)); + auto modifyData = std::make_unique(*model, index, new_); if (modifyCell.get()) { diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index b10efaa3a4..939316fa60 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -70,11 +70,11 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, bool fsStrict, const Files::Pat mReader (nullptr), mDialogue (nullptr), mReaderIndex(1), mFsStrict(fsStrict), mDataPaths(dataPaths), mArchives(archives) { - mVFS.reset(new VFS::Manager(mFsStrict)); + mVFS = std::make_unique(mFsStrict); VFS::registerArchives(mVFS.get(), Files::Collections(mDataPaths, !mFsStrict), mArchives, true); mResourcesManager.setVFS(mVFS.get()); - mResourceSystem.reset(new Resource::ResourceSystem(mVFS.get())); + mResourceSystem = std::make_unique(mVFS.get()); Shader::ShaderManager::DefineMap defines = mResourceSystem->getSceneManager()->getShaderManager().getGlobalDefines(); Shader::ShaderManager::DefineMap shadowDefines = SceneUtil::ShadowManager::getShadowsDisabledDefines(); @@ -602,7 +602,7 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, bool fsStrict, const Files::Pat UniversalId::Type_Video); addModel (new IdTable (&mMetaData), UniversalId::Type_MetaData); - mActorAdapter.reset(new ActorAdapter(*this)); + mActorAdapter = std::make_unique(*this); mRefLoadCache.clear(); // clear here rather than startLoading() and continueLoading() for multiple content files } @@ -963,7 +963,7 @@ int CSMWorld::Data::getTotalRecords (const std::vector& { int records = 0; - std::unique_ptr reader = std::unique_ptr(new ESM::ESMReader); + std::unique_ptr reader = std::make_unique(); for (unsigned int i = 0; i < files.size(); ++i) { @@ -1032,7 +1032,7 @@ void CSMWorld::Data::loadFallbackEntries() ESM::Static newMarker; newMarker.mId = marker.first; newMarker.mModel = marker.second; - std::unique_ptr > record(new CSMWorld::Record); + auto record = std::make_unique>(); record->mBase = newMarker; record->mState = CSMWorld::RecordBase::State_BaseOnly; mReferenceables.appendRecord (std::move(record), CSMWorld::UniversalId::Type_Static); @@ -1046,7 +1046,7 @@ void CSMWorld::Data::loadFallbackEntries() ESM::Door newMarker; newMarker.mId = marker.first; newMarker.mModel = marker.second; - std::unique_ptr > record(new CSMWorld::Record); + auto record = std::make_unique>(); record->mBase = newMarker; record->mState = CSMWorld::RecordBase::State_BaseOnly; mReferenceables.appendRecord (std::move(record), CSMWorld::UniversalId::Type_Door); diff --git a/apps/opencs/model/world/idcollection.cpp b/apps/opencs/model/world/idcollection.cpp index d06a47e32b..802ffe2487 100644 --- a/apps/opencs/model/world/idcollection.cpp +++ b/apps/opencs/model/world/idcollection.cpp @@ -32,7 +32,7 @@ namespace CSMWorld return -1; } - std::unique_ptr > baseRecord(new Record(this->getRecord(index))); + auto baseRecord = std::make_unique>(this->getRecord(index)); baseRecord->mState = RecordBase::State_Deleted; this->setRecord(index, std::move(baseRecord)); return index; diff --git a/apps/opencs/model/world/idcollection.hpp b/apps/opencs/model/world/idcollection.hpp index 9261d287f5..d246dc6852 100644 --- a/apps/opencs/model/world/idcollection.hpp +++ b/apps/opencs/model/world/idcollection.hpp @@ -84,7 +84,7 @@ namespace CSMWorld return -1; } - std::unique_ptr > baseRecord(new Record(this->getRecord(index))); + auto baseRecord = std::make_unique>(this->getRecord(index)); baseRecord->mState = RecordBase::State_Deleted; this->setRecord(index, std::move(baseRecord)); return index; @@ -103,7 +103,7 @@ namespace CSMWorld if (index==-1) { // new record - std::unique_ptr > record2(new Record); + auto record2 = std::make_unique>(); record2->mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly; (base ? record2->mBase : record2->mModified) = record; @@ -113,8 +113,7 @@ namespace CSMWorld else { // old record - std::unique_ptr > record2( - new Record(Collection::getRecord(index))); + auto record2 = std::make_unique>(Collection::getRecord(index)); if (base) record2->mBase = record; @@ -146,8 +145,7 @@ namespace CSMWorld } else { - std::unique_ptr > record2( - new Record(Collection::getRecord(index))); + auto record2 = std::make_unique>(Collection::getRecord(index)); record2->mState = RecordBase::State_Deleted; this->setRecord(index, std::move(record2)); } diff --git a/apps/opencs/model/world/infocollection.cpp b/apps/opencs/model/world/infocollection.cpp index a7cdc28d28..ced7938fc2 100644 --- a/apps/opencs/model/world/infocollection.cpp +++ b/apps/opencs/model/world/infocollection.cpp @@ -77,7 +77,7 @@ void CSMWorld::InfoCollection::load (const Info& record, bool base) if (index==-1) { // new record - std::unique_ptr > record2(new Record); + auto record2 = std::make_unique>(); record2->mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly; (base ? record2->mBase : record2->mModified) = record; @@ -86,7 +86,7 @@ void CSMWorld::InfoCollection::load (const Info& record, bool base) else { // old record - std::unique_ptr > record2(new Record(getRecord(index))); + auto record2 = std::make_unique>(getRecord(index)); if (base) record2->mBase = record; @@ -220,7 +220,7 @@ void CSMWorld::InfoCollection::load (ESM::ESMReader& reader, bool base, const ES } else { - std::unique_ptr > record(new Record(getRecord(index))); + auto record = std::make_unique>(getRecord(index)); record->mState = RecordBase::State_Deleted; setRecord (index, std::move(record)); } @@ -281,7 +281,7 @@ void CSMWorld::InfoCollection::removeDialogueInfos(const std::string& dialogueId } else { - std::unique_ptr > record2(new Record(record)); + auto record2 = std::make_unique>(record); record2->mState = RecordBase::State_Deleted; setRecord(range.first - getRecords().begin(), std::move(record2)); } @@ -335,7 +335,7 @@ void CSMWorld::InfoCollection::removeRows (int index, int count) void CSMWorld::InfoCollection::appendBlankRecord (const std::string& id, UniversalId::Type type) { - std::unique_ptr > record2(new Record); + auto record2 = std::make_unique>(); record2->mState = Record::State_ModifiedOnly; record2->mModified.blank(); diff --git a/apps/opencs/model/world/nestedidcollection.hpp b/apps/opencs/model/world/nestedidcollection.hpp index 4af864eb42..1928786c78 100644 --- a/apps/opencs/model/world/nestedidcollection.hpp +++ b/apps/opencs/model/world/nestedidcollection.hpp @@ -90,7 +90,7 @@ namespace CSMWorld template void NestedIdCollection::addNestedRow(int row, int column, int position) { - std::unique_ptr > record(new Record); + auto record = std::make_unique>(); record->assign(Collection::getRecord(row)); getAdapter(Collection::getColumn(column)).addRow(*record, position); @@ -101,7 +101,7 @@ namespace CSMWorld template void NestedIdCollection::removeNestedRows(int row, int column, int subRow) { - std::unique_ptr > record(new Record); + auto record = std::make_unique>(); record->assign(Collection::getRecord(row)); getAdapter(Collection::getColumn(column)).removeRow(*record, subRow); @@ -121,7 +121,7 @@ namespace CSMWorld void NestedIdCollection::setNestedData(int row, int column, const QVariant& data, int subRow, int subColumn) { - std::unique_ptr > record(new Record); + auto record = std::make_unique>(); record->assign(Collection::getRecord(row)); getAdapter(Collection::getColumn(column)).setData( @@ -142,7 +142,7 @@ namespace CSMWorld void NestedIdCollection::setNestedTable(int row, int column, const CSMWorld::NestedTableWrapperBase& nestedTable) { - std::unique_ptr > record(new Record); + auto record = std::make_unique>(); record->assign(Collection::getRecord(row)); getAdapter(Collection::getColumn(column)).setTable( diff --git a/apps/opencs/model/world/nestedinfocollection.cpp b/apps/opencs/model/world/nestedinfocollection.cpp index d404bb9a63..e2e90c49d1 100644 --- a/apps/opencs/model/world/nestedinfocollection.cpp +++ b/apps/opencs/model/world/nestedinfocollection.cpp @@ -35,7 +35,7 @@ namespace CSMWorld void NestedInfoCollection::addNestedRow(int row, int column, int position) { - std::unique_ptr > record(new Record); + auto record = std::make_unique>(); record->assign(Collection >::getRecord(row)); getAdapter(Collection >::getColumn(column)).addRow(*record, position); @@ -45,7 +45,7 @@ namespace CSMWorld void NestedInfoCollection::removeNestedRows(int row, int column, int subRow) { - std::unique_ptr > record(new Record); + auto record = std::make_unique>(); record->assign(Collection >::getRecord(row)); getAdapter(Collection >::getColumn(column)).removeRow(*record, subRow); @@ -63,7 +63,7 @@ namespace CSMWorld void NestedInfoCollection::setNestedData(int row, int column, const QVariant& data, int subRow, int subColumn) { - std::unique_ptr > record(new Record); + auto record = std::make_unique>(); record->assign(Collection >::getRecord(row)); getAdapter(Collection >::getColumn(column)).setData( @@ -82,7 +82,7 @@ namespace CSMWorld void NestedInfoCollection::setNestedTable(int row, int column, const CSMWorld::NestedTableWrapperBase& nestedTable) { - std::unique_ptr > record(new Record); + auto record = std::make_unique>(); record->assign(Collection >::getRecord(row)); getAdapter(Collection >::getColumn(column)).setTable( diff --git a/apps/opencs/model/world/refcollection.cpp b/apps/opencs/model/world/refcollection.cpp index 76a3b7311a..804a13cf7b 100644 --- a/apps/opencs/model/world/refcollection.cpp +++ b/apps/opencs/model/world/refcollection.cpp @@ -123,7 +123,7 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool ref.mId = getRecord(index).get().mId; ref.mIdNum = extractIdNum(ref.mId); - std::unique_ptr > record(new Record); + auto record = std::make_unique>(); // TODO: check whether a base record be moved record->mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly; (base ? record->mBase : record->mModified) = std::move(ref); @@ -158,7 +158,7 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool } else { - std::unique_ptr > record(new Record(getRecord(index))); + auto record = std::make_unique>(getRecord(index)); record->mState = RecordBase::State_Deleted; setRecord(index, std::move(record)); } @@ -174,7 +174,7 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool cache.emplace(refNum, ref.mIdNum); - std::unique_ptr > record(new Record); + auto record = std::make_unique>(); record->mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly; (base ? record->mBase : record->mModified) = std::move(ref); @@ -205,7 +205,7 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool ref.mId = getRecord(index).get().mId; ref.mIdNum = extractIdNum(ref.mId); - std::unique_ptr > record(new Record(getRecord(index))); + auto record = std::make_unique>(getRecord(index)); record->mState = base ? RecordBase::State_BaseOnly : RecordBase::State_Modified; (base ? record->mBase : record->mModified) = std::move(ref); @@ -273,7 +273,7 @@ void CSMWorld::RefCollection::removeRows (int index, int count) void CSMWorld::RefCollection::appendBlankRecord (const std::string& id, UniversalId::Type type) { - std::unique_ptr > record(new Record); + auto record = std::make_unique>(); record->mState = Record::State_ModifiedOnly; record->mModified.blank(); @@ -288,15 +288,15 @@ void CSMWorld::RefCollection::cloneRecord (const std::string& origin, const std::string& destination, const UniversalId::Type type) { - std::unique_ptr > copy(new Record); + auto copy = std::make_unique>(); - copy->mModified = getRecord(origin).get(); - copy->mState = RecordBase::State_ModifiedOnly; + copy->mModified = getRecord(origin).get(); + copy->mState = RecordBase::State_ModifiedOnly; - copy->get().mId = destination; - copy->get().mIdNum = extractIdNum(destination); + copy->get().mId = destination; + copy->get().mIdNum = extractIdNum(destination); - insertRecord(std::move(copy), getAppendIndex(destination, type)); // call RefCollection::insertRecord() + insertRecord(std::move(copy), getAppendIndex(destination, type)); // call RefCollection::insertRecord() } int CSMWorld::RefCollection::searchId(std::string_view id) const diff --git a/apps/opencs/model/world/refiddata.hpp b/apps/opencs/model/world/refiddata.hpp index ff2232dffe..0b9fc66b53 100644 --- a/apps/opencs/model/world/refiddata.hpp +++ b/apps/opencs/model/world/refiddata.hpp @@ -130,7 +130,7 @@ namespace CSMWorld template void RefIdDataContainer::appendRecord (const std::string& id, bool base) { - std::unique_ptr > record(new Record); + auto record = std::make_unique>(); record->mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly; diff --git a/apps/opencs/view/render/cell.cpp b/apps/opencs/view/render/cell.cpp index b6aa5c2fd7..3395e90e11 100644 --- a/apps/opencs/view/render/cell.cpp +++ b/apps/opencs/view/render/cell.cpp @@ -85,7 +85,7 @@ bool CSVRender::Cell::addObjects (int start, int end) { std::string id = Misc::StringUtils::lowerCase (collection.getRecord (i).get().mId); - std::unique_ptr object (new Object (mData, mCellNode, id, false)); + auto object = std::make_unique(mData, mCellNode, id, false); if (mSubModeElementMask & Mask_Reference) object->setSubMode (mSubMode); @@ -128,14 +128,14 @@ void CSVRender::Cell::updateLand() } else { - mTerrain.reset(new Terrain::TerrainGrid(mCellNode, mCellNode, - mData.getResourceSystem().get(), mTerrainStorage, Mask_Terrain)); + mTerrain = std::make_unique(mCellNode, mCellNode, + mData.getResourceSystem().get(), mTerrainStorage, Mask_Terrain); } mTerrain->loadCell(esmLand.mX, esmLand.mY); if (!mCellBorder) - mCellBorder.reset(new CellBorder(mCellNode, mCoordinates)); + mCellBorder = std::make_unique(mCellNode, mCoordinates); mCellBorder->buildShape(esmLand); @@ -186,8 +186,8 @@ CSVRender::Cell::Cell (CSMWorld::Data& data, osg::Group* rootNode, const std::st updateLand(); - mPathgrid.reset(new Pathgrid(mData, mCellNode, mId, mCoordinates)); - mCellWater.reset(new CellWater(mData, mCellNode, mId, mCoordinates)); + mPathgrid = std::make_unique(mData, mCellNode, mId, mCoordinates); + mCellWater = std::make_unique(mData, mCellNode, mId, mCoordinates); } } @@ -546,7 +546,7 @@ void CSVRender::Cell::setCellArrows (int mask) if (enable!=(mCellArrows[i].get()!=nullptr)) { if (enable) - mCellArrows[i].reset (new CellArrow (mCellNode, direction, mCoordinates)); + mCellArrows[i] = std::make_unique(mCellNode, direction, mCoordinates); else mCellArrows[i].reset (nullptr); } @@ -567,7 +567,7 @@ void CSVRender::Cell::setCellMarker() } if (!isInteriorCell) { - mCellMarker.reset(new CellMarker(mCellNode, mCoordinates, cellExists)); + mCellMarker = std::make_unique(mCellNode, mCoordinates, cellExists); } } diff --git a/apps/opencs/view/render/object.cpp b/apps/opencs/view/render/object.cpp index 9f4fd29966..2def43df70 100644 --- a/apps/opencs/view/render/object.cpp +++ b/apps/opencs/view/render/object.cpp @@ -117,7 +117,7 @@ void CSVRender::Object::update() { if (recordType == CSMWorld::UniversalId::Type_Npc || recordType == CSMWorld::UniversalId::Type_Creature) { - if (!mActor) mActor.reset(new Actor(mReferenceableId, mData)); + if (!mActor) mActor = std::make_unique(mReferenceableId, mData); mActor->update(); mBaseNode->addChild(mActor->getBaseNode()); } diff --git a/apps/opencs/view/render/pagedworldspacewidget.cpp b/apps/opencs/view/render/pagedworldspacewidget.cpp index a0b4de979d..09306174c1 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.cpp +++ b/apps/opencs/view/render/pagedworldspacewidget.cpp @@ -55,8 +55,8 @@ bool CSVRender::PagedWorldspaceWidget::adjustCells() { modified = true; - std::unique_ptr cell (new Cell (mDocument.getData(), mRootNode, - iter->first.getId (mWorldspace), deleted)); + auto cell = std::make_unique(mDocument.getData(), mRootNode, + iter->first.getId (mWorldspace), deleted); delete iter->second; iter->second = cell.release(); @@ -443,9 +443,7 @@ void CSVRender::PagedWorldspaceWidget::addCellToScene ( bool deleted = index==-1 || cells.getRecord (index).mState==CSMWorld::RecordBase::State_Deleted; - std::unique_ptr cell ( - new Cell (mDocument.getData(), mRootNode, coordinates.getId (mWorldspace), - deleted)); + auto cell = std::make_unique(mDocument.getData(), mRootNode, coordinates.getId (mWorldspace), deleted); EditMode *editMode = getEditMode(); cell->setSubMode (editMode->getSubMode(), editMode->getInteractionMask()); diff --git a/apps/opencs/view/render/terrainshapemode.cpp b/apps/opencs/view/render/terrainshapemode.cpp index baae1807fd..bd023b9b76 100644 --- a/apps/opencs/view/render/terrainshapemode.cpp +++ b/apps/opencs/view/render/terrainshapemode.cpp @@ -41,7 +41,7 @@ void CSVRender::TerrainShapeMode::activate(CSVWidget::SceneToolbar* toolbar) { if (!mTerrainShapeSelection) { - mTerrainShapeSelection.reset(new TerrainSelection(mParentNode, &getWorldspaceWidget(), TerrainSelectionType::Shape)); + mTerrainShapeSelection = std::make_shared(mParentNode, &getWorldspaceWidget(), TerrainSelectionType::Shape); } if(!mShapeBrushScenetool) @@ -56,7 +56,7 @@ void CSVRender::TerrainShapeMode::activate(CSVWidget::SceneToolbar* toolbar) } if (!mBrushDraw) - mBrushDraw.reset(new BrushDraw(mParentNode)); + mBrushDraw = std::make_unique(mParentNode); EditMode::activate(toolbar); toolbar->addTool (mShapeBrushScenetool); @@ -956,15 +956,15 @@ bool CSVRender::TerrainShapeMode::limitAlteredHeights(const CSMWorld::CellCoordi // Check for height limits on x-axis if (leftHeight - thisHeight > limitHeightChange) - limitedAlteredHeightXAxis.reset(new float(leftHeight - limitHeightChange - (thisHeight - thisAlteredHeight))); + limitedAlteredHeightXAxis = std::make_unique(leftHeight - limitHeightChange - (thisHeight - thisAlteredHeight)); else if (leftHeight - thisHeight < -limitHeightChange) - limitedAlteredHeightXAxis.reset(new float(leftHeight + limitHeightChange - (thisHeight - thisAlteredHeight))); + limitedAlteredHeightXAxis = std::make_unique(leftHeight + limitHeightChange - (thisHeight - thisAlteredHeight)); // Check for height limits on y-axis if (upHeight - thisHeight > limitHeightChange) - limitedAlteredHeightYAxis.reset(new float(upHeight - limitHeightChange - (thisHeight - thisAlteredHeight))); + limitedAlteredHeightYAxis = std::make_unique(upHeight - limitHeightChange - (thisHeight - thisAlteredHeight)); else if (upHeight - thisHeight < -limitHeightChange) - limitedAlteredHeightYAxis.reset(new float(upHeight + limitHeightChange - (thisHeight - thisAlteredHeight))); + limitedAlteredHeightYAxis = std::make_unique(upHeight + limitHeightChange - (thisHeight - thisAlteredHeight)); // Limit altered height value based on x or y, whichever is the smallest compareAndLimit(cellCoords, inCellX, inCellY, limitedAlteredHeightXAxis.get(), limitedAlteredHeightYAxis.get(), &steepnessIsWithinLimits); @@ -985,15 +985,15 @@ bool CSVRender::TerrainShapeMode::limitAlteredHeights(const CSMWorld::CellCoordi // Check for height limits on x-axis if (rightHeight - thisHeight > limitHeightChange) - limitedAlteredHeightXAxis.reset(new float(rightHeight - limitHeightChange - (thisHeight - thisAlteredHeight))); + limitedAlteredHeightXAxis = std::make_unique(rightHeight - limitHeightChange - (thisHeight - thisAlteredHeight)); else if (rightHeight - thisHeight < -limitHeightChange) - limitedAlteredHeightXAxis.reset(new float(rightHeight + limitHeightChange - (thisHeight - thisAlteredHeight))); + limitedAlteredHeightXAxis = std::make_unique(rightHeight + limitHeightChange - (thisHeight - thisAlteredHeight)); // Check for height limits on y-axis if (downHeight - thisHeight > limitHeightChange) - limitedAlteredHeightYAxis.reset(new float(downHeight - limitHeightChange - (thisHeight - thisAlteredHeight))); + limitedAlteredHeightYAxis = std::make_unique(downHeight - limitHeightChange - (thisHeight - thisAlteredHeight)); else if (downHeight - thisHeight < -limitHeightChange) - limitedAlteredHeightYAxis.reset(new float(downHeight + limitHeightChange - (thisHeight - thisAlteredHeight))); + limitedAlteredHeightYAxis = std::make_unique(downHeight + limitHeightChange - (thisHeight - thisAlteredHeight)); // Limit altered height value based on x or y, whichever is the smallest compareAndLimit(cellCoords, inCellX, inCellY, limitedAlteredHeightXAxis.get(), limitedAlteredHeightYAxis.get(), &steepnessIsWithinLimits); @@ -1298,8 +1298,7 @@ bool CSVRender::TerrainShapeMode::allowLandShapeEditing(const std::string& cellI if (mode=="Create cell and land, then edit" && useTool) { - std::unique_ptr createCommand ( - new CSMWorld::CreateCommand (cellTable, cellId)); + auto createCommand = std::make_unique(cellTable, cellId); int parentIndex = cellTable.findColumnIndex (CSMWorld::Columns::ColumnId_Cell); int index = cellTable.findNestedColumnIndex (parentIndex, CSMWorld::Columns::ColumnId_Interior); createCommand->addNestedValue (parentIndex, index, false); diff --git a/apps/opencs/view/render/terraintexturemode.cpp b/apps/opencs/view/render/terraintexturemode.cpp index 113acd2a21..226ac36f3b 100644 --- a/apps/opencs/view/render/terraintexturemode.cpp +++ b/apps/opencs/view/render/terraintexturemode.cpp @@ -65,11 +65,11 @@ void CSVRender::TerrainTextureMode::activate(CSVWidget::SceneToolbar* toolbar) if (!mTerrainTextureSelection) { - mTerrainTextureSelection.reset(new TerrainSelection(mParentNode, &getWorldspaceWidget(), TerrainSelectionType::Texture)); + mTerrainTextureSelection = std::make_shared(mParentNode, &getWorldspaceWidget(), TerrainSelectionType::Texture); } if (!mBrushDraw) - mBrushDraw.reset(new BrushDraw(mParentNode, true)); + mBrushDraw = std::make_unique(mParentNode, true); EditMode::activate(toolbar); toolbar->addTool (mTextureBrushScenetool); @@ -662,8 +662,7 @@ bool CSVRender::TerrainTextureMode::allowLandTextureEditing(std::string cellId) if (mode=="Create cell and land, then edit") { - std::unique_ptr createCommand ( - new CSMWorld::CreateCommand (cellTable, cellId)); + auto createCommand = std::make_unique(cellTable, cellId); int parentIndex = cellTable.findColumnIndex (CSMWorld::Columns::ColumnId_Cell); int index = cellTable.findNestedColumnIndex (parentIndex, CSMWorld::Columns::ColumnId_Interior); createCommand->addNestedValue (parentIndex, index, false); diff --git a/apps/opencs/view/render/unpagedworldspacewidget.cpp b/apps/opencs/view/render/unpagedworldspacewidget.cpp index 20dc5b8d1e..943de15691 100644 --- a/apps/opencs/view/render/unpagedworldspacewidget.cpp +++ b/apps/opencs/view/render/unpagedworldspacewidget.cpp @@ -56,7 +56,7 @@ CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget (const std::string& update(); - mCell.reset (new Cell (document.getData(), mRootNode, mCellId)); + mCell = std::make_unique(document.getData(), mRootNode, mCellId); } void CSVRender::UnpagedWorldspaceWidget::cellDataChanged (const QModelIndex& topLeft, @@ -105,7 +105,7 @@ bool CSVRender::UnpagedWorldspaceWidget::handleDrop (const std::vectorgetId(); - mCell.reset (new Cell (getDocument().getData(), mRootNode, mCellId)); + mCell = std::make_unique(getDocument().getData(), mRootNode, mCellId); mCamPositionSet = false; mOrbitCamControl->reset(); diff --git a/apps/opencs/view/world/creator.hpp b/apps/opencs/view/world/creator.hpp index 516f71f15c..7c61c6e6be 100644 --- a/apps/opencs/view/world/creator.hpp +++ b/apps/opencs/view/world/creator.hpp @@ -96,7 +96,7 @@ namespace CSVWorld Creator *CreatorFactory::makeCreator (CSMDoc::Document& document, const CSMWorld::UniversalId& id) const { - std::unique_ptr creator (new CreatorT (document.getData(), document.getUndoStack(), id)); + auto creator = std::make_unique(document.getData(), document.getUndoStack(), id); creator->setScope (scope); diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index 152472f504..311c80a490 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -133,7 +133,7 @@ void CSVWorld::DialogueDelegateDispatcherProxy::editorDataCommited() void CSVWorld::DialogueDelegateDispatcherProxy::setIndex(const QModelIndex& index) { - mIndexWrapper.reset(new refWrapper(index)); + mIndexWrapper = std::make_unique(index); } QWidget* CSVWorld::DialogueDelegateDispatcherProxy::getEditor() const diff --git a/apps/opencs/view/world/genericcreator.cpp b/apps/opencs/view/world/genericcreator.cpp index 8ae8f8764d..7061c8a8b5 100644 --- a/apps/opencs/view/world/genericcreator.cpp +++ b/apps/opencs/view/world/genericcreator.cpp @@ -238,13 +238,13 @@ void CSVWorld::GenericCreator::create() if (mCloneMode) { - command.reset (new CSMWorld::CloneCommand ( - dynamic_cast (*mData.getTableModel(mListId)), mClonedId, id, mClonedType)); + command = std::make_unique( + dynamic_cast (*mData.getTableModel(mListId)), mClonedId, id, mClonedType); } else { - command.reset (new CSMWorld::CreateCommand ( - dynamic_cast (*mData.getTableModel (mListId)), id)); + command = std::make_unique( + dynamic_cast (*mData.getTableModel (mListId)), id); } From c231c3e3605d465248a28299350932347257ab3f Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Sun, 29 May 2022 13:25:59 +0200 Subject: [PATCH 4/4] Replace new with make_unique in essimporter --- apps/essimporter/importer.cpp | 64 +++++++++++++++++------------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/apps/essimporter/importer.cpp b/apps/essimporter/importer.cpp index 0eb377c219..577185b8d9 100644 --- a/apps/essimporter/importer.cpp +++ b/apps/essimporter/importer.cpp @@ -273,38 +273,38 @@ namespace ESSImport const unsigned int recSPLM = ESM::fourCC("SPLM"); std::map> converters; - converters[ESM::REC_GLOB] = std::unique_ptr(new ConvertGlobal()); - converters[ESM::REC_BOOK] = std::unique_ptr(new ConvertBook()); - converters[ESM::REC_NPC_] = std::unique_ptr(new ConvertNPC()); - converters[ESM::REC_CREA] = std::unique_ptr(new ConvertCREA()); - converters[ESM::REC_NPCC] = std::unique_ptr(new ConvertNPCC()); - converters[ESM::REC_CREC] = std::unique_ptr(new ConvertCREC()); - converters[recREFR ] = std::unique_ptr(new ConvertREFR()); - converters[recPCDT ] = std::unique_ptr(new ConvertPCDT()); - converters[recFMAP ] = std::unique_ptr(new ConvertFMAP()); - converters[recKLST ] = std::unique_ptr(new ConvertKLST()); - converters[recSTLN ] = std::unique_ptr(new ConvertSTLN()); - converters[recGAME ] = std::unique_ptr(new ConvertGAME()); - converters[ESM::REC_CELL] = std::unique_ptr(new ConvertCell()); - converters[ESM::REC_ALCH] = std::unique_ptr(new DefaultConverter()); - converters[ESM::REC_CLAS] = std::unique_ptr(new ConvertClass()); - converters[ESM::REC_SPEL] = std::unique_ptr(new DefaultConverter()); - converters[ESM::REC_ARMO] = std::unique_ptr(new DefaultConverter()); - converters[ESM::REC_WEAP] = std::unique_ptr(new DefaultConverter()); - converters[ESM::REC_CLOT] = std::unique_ptr(new DefaultConverter()); - converters[ESM::REC_ENCH] = std::unique_ptr(new DefaultConverter()); - converters[ESM::REC_WEAP] = std::unique_ptr(new DefaultConverter()); - converters[ESM::REC_LEVC] = std::unique_ptr(new DefaultConverter()); - converters[ESM::REC_LEVI] = std::unique_ptr(new DefaultConverter()); - converters[ESM::REC_CNTC] = std::unique_ptr(new ConvertCNTC()); - converters[ESM::REC_FACT] = std::unique_ptr(new ConvertFACT()); - converters[ESM::REC_INFO] = std::unique_ptr(new ConvertINFO()); - converters[ESM::REC_DIAL] = std::unique_ptr(new ConvertDIAL()); - converters[ESM::REC_QUES] = std::unique_ptr(new ConvertQUES()); - converters[recJOUR ] = std::unique_ptr(new ConvertJOUR()); - converters[ESM::REC_SCPT] = std::unique_ptr(new ConvertSCPT()); - converters[ESM::REC_PROJ] = std::unique_ptr(new ConvertPROJ()); - converters[recSPLM] = std::unique_ptr(new ConvertSPLM()); + converters[ESM::REC_GLOB] = std::make_unique(); + converters[ESM::REC_BOOK] = std::make_unique(); + converters[ESM::REC_NPC_] = std::make_unique(); + converters[ESM::REC_CREA] = std::make_unique(); + converters[ESM::REC_NPCC] = std::make_unique(); + converters[ESM::REC_CREC] = std::make_unique(); + converters[recREFR ] = std::make_unique(); + converters[recPCDT ] = std::make_unique(); + converters[recFMAP ] = std::make_unique(); + converters[recKLST ] = std::make_unique(); + converters[recSTLN ] = std::make_unique(); + converters[recGAME ] = std::make_unique(); + converters[ESM::REC_CELL] = std::make_unique(); + converters[ESM::REC_ALCH] = std::make_unique>(); + converters[ESM::REC_CLAS] = std::make_unique(); + converters[ESM::REC_SPEL] = std::make_unique>(); + converters[ESM::REC_ARMO] = std::make_unique>(); + converters[ESM::REC_WEAP] = std::make_unique>(); + converters[ESM::REC_CLOT] = std::make_unique>(); + converters[ESM::REC_ENCH] = std::make_unique>(); + converters[ESM::REC_WEAP] = std::make_unique>(); + converters[ESM::REC_LEVC] = std::make_unique>(); + converters[ESM::REC_LEVI] = std::make_unique>(); + converters[ESM::REC_CNTC] = std::make_unique(); + converters[ESM::REC_FACT] = std::make_unique(); + converters[ESM::REC_INFO] = std::make_unique(); + converters[ESM::REC_DIAL] = std::make_unique(); + converters[ESM::REC_QUES] = std::make_unique(); + converters[recJOUR ] = std::make_unique(); + converters[ESM::REC_SCPT] = std::make_unique(); + converters[ESM::REC_PROJ] = std::make_unique(); + converters[recSPLM] = std::make_unique(); // TODO: // - REGN (weather in certain regions?)