Replace shared_ptr by unique_ptr

pull/3226/head
elsid 2 years ago
parent cfc951d645
commit df092b558b
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40

@ -6,6 +6,8 @@
#include <osg/Vec2f>
#include <MyGUI_ITexture.h>
#include "windowpinnablebase.hpp"
#include <components/esm3/cellid.hpp>
@ -142,8 +144,8 @@ namespace MWGui
MyGUI::ImageBox* mMapWidget;
MyGUI::ImageBox* mFogWidget;
std::shared_ptr<MyGUI::ITexture> mMapTexture;
std::shared_ptr<MyGUI::ITexture> mFogTexture;
std::unique_ptr<MyGUI::ITexture> mMapTexture;
std::unique_ptr<MyGUI::ITexture> mFogTexture;
int mCellX;
int mCellY;
};

@ -61,7 +61,7 @@ public:
~PartHolder();
osg::ref_ptr<osg::Node> getNode()
const osg::ref_ptr<osg::Node>& getNode() const
{
return mNode;
}
@ -72,7 +72,7 @@ private:
void operator= (const PartHolder&);
PartHolder(const PartHolder&);
};
typedef std::shared_ptr<PartHolder> PartHolderPtr;
using PartHolderPtr = std::unique_ptr<PartHolder>;
struct EffectParams
{

@ -135,7 +135,7 @@ void LocalMap::saveFogOfWar(MWWorld::CellStore* cell)
segment.saveFogOfWar(fog->mFogTextures.back());
cell->setFog(fog.release());
cell->setFog(std::move(fog));
}
}
else
@ -169,7 +169,7 @@ void LocalMap::saveFogOfWar(MWWorld::CellStore* cell)
}
}
cell->setFog(fog.release());
cell->setFog(std::move(fog));
}
}

@ -425,8 +425,8 @@ int NpcAnimation::getSlot(const osg::NodePath &path) const
{
for (int i=0; i<ESM::PRT_Count; ++i)
{
PartHolderPtr part = mObjectParts[i];
if (!part.get())
const PartHolder* const part = mObjectParts[i].get();
if (part == nullptr)
continue;
if (std::find(path.begin(), path.end(), part->getNode().get()) != path.end())
{
@ -1023,8 +1023,8 @@ void NpcAnimation::releaseArrow(float attackStrength)
osg::Group* NpcAnimation::getArrowBone()
{
PartHolderPtr part = mObjectParts[ESM::PRT_Weapon];
if (!part)
const PartHolder* const part = mObjectParts[ESM::PRT_Weapon].get();
if (part == nullptr)
return nullptr;
const MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
@ -1048,8 +1048,8 @@ osg::Group* NpcAnimation::getArrowBone()
osg::Node* NpcAnimation::getWeaponNode()
{
PartHolderPtr part = mObjectParts[ESM::PRT_Weapon];
if (!part)
const PartHolder* const part = mObjectParts[ESM::PRT_Weapon].get();
if (part == nullptr)
return nullptr;
return part->getNode();
}

@ -153,9 +153,9 @@ namespace MWSound
std::shared_ptr<Video::MovieAudioDecoder> MovieAudioFactory::createDecoder(Video::VideoState* videoState)
std::unique_ptr<Video::MovieAudioDecoder> MovieAudioFactory::createDecoder(Video::VideoState* videoState)
{
std::shared_ptr<MWSound::MovieAudioDecoder> decoder(new MWSound::MovieAudioDecoder(videoState));
std::unique_ptr<MWSound::MovieAudioDecoder> decoder(new MWSound::MovieAudioDecoder(videoState));
decoder->setupFormat();
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();

@ -8,7 +8,7 @@ namespace MWSound
class MovieAudioFactory : public Video::MovieAudioFactory
{
std::shared_ptr<Video::MovieAudioDecoder> createDecoder(Video::VideoState* videoState) override;
std::unique_ptr<Video::MovieAudioDecoder> createDecoder(Video::VideoState* videoState) override;
};
}

@ -1029,9 +1029,9 @@ namespace MWWorld
return !(left==right);
}
void CellStore::setFog(ESM::FogState *fog)
void CellStore::setFog(std::unique_ptr<ESM::FogState>&& fog)
{
mFogState.reset(fog);
mFogState = std::move(fog);
}
ESM::FogState* CellStore::getFog() const

@ -31,6 +31,7 @@
#include <components/esm3/loadnpc.hpp>
#include <components/esm3/loadmisc.hpp>
#include <components/esm3/loadbody.hpp>
#include <components/esm3/fogstate.hpp>
#include "timestamp.hpp"
#include "ptr.hpp"
@ -39,7 +40,6 @@ namespace ESM
{
struct Cell;
struct CellState;
struct FogState;
struct CellId;
struct RefNum;
}
@ -66,7 +66,7 @@ namespace MWWorld
// Even though fog actually belongs to the player and not cells,
// it makes sense to store it here since we need it once for each cell.
// Note this is nullptr until the cell is explored to save some memory
std::shared_ptr<ESM::FogState> mFogState;
std::unique_ptr<ESM::FogState> mFogState;
const ESM::Cell *mCell;
State mState;
@ -254,7 +254,7 @@ namespace MWWorld
void setWaterLevel (float level);
void setFog (ESM::FogState* fog);
void setFog(std::unique_ptr<ESM::FogState>&& fog);
///< \note Takes ownership of the pointer
ESM::FogState* getFog () const;

@ -10,7 +10,7 @@ namespace Video
class MovieAudioFactory
{
public:
virtual std::shared_ptr<MovieAudioDecoder> createDecoder(VideoState* videoState) = 0;
virtual std::unique_ptr<MovieAudioDecoder> createDecoder(VideoState* videoState) = 0;
virtual ~MovieAudioFactory() {}
};

@ -161,7 +161,7 @@ struct VideoState {
osg::ref_ptr<osg::Texture2D> mTexture;
MovieAudioFactory* mAudioFactory;
std::shared_ptr<MovieAudioDecoder> mAudioDecoder;
std::unique_ptr<MovieAudioDecoder> mAudioDecoder;
ExternalClock mExternalClock;

Loading…
Cancel
Save