1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-06 12:41:31 +00:00

Merge branch 'uniquely_made' into 'master'

Replace operator new with make_unique

See merge request OpenMW/openmw!1945
This commit is contained in:
jvoisin 2022-05-29 13:10:22 +00:00
commit 6c400bcbc3
76 changed files with 271 additions and 283 deletions

View file

@ -273,38 +273,38 @@ namespace ESSImport
const unsigned int recSPLM = ESM::fourCC("SPLM"); const unsigned int recSPLM = ESM::fourCC("SPLM");
std::map<unsigned int, std::unique_ptr<Converter>> converters; std::map<unsigned int, std::unique_ptr<Converter>> converters;
converters[ESM::REC_GLOB] = std::unique_ptr<Converter>(new ConvertGlobal()); converters[ESM::REC_GLOB] = std::make_unique<ConvertGlobal>();
converters[ESM::REC_BOOK] = std::unique_ptr<Converter>(new ConvertBook()); converters[ESM::REC_BOOK] = std::make_unique<ConvertBook>();
converters[ESM::REC_NPC_] = std::unique_ptr<Converter>(new ConvertNPC()); converters[ESM::REC_NPC_] = std::make_unique<ConvertNPC>();
converters[ESM::REC_CREA] = std::unique_ptr<Converter>(new ConvertCREA()); converters[ESM::REC_CREA] = std::make_unique<ConvertCREA>();
converters[ESM::REC_NPCC] = std::unique_ptr<Converter>(new ConvertNPCC()); converters[ESM::REC_NPCC] = std::make_unique<ConvertNPCC>();
converters[ESM::REC_CREC] = std::unique_ptr<Converter>(new ConvertCREC()); converters[ESM::REC_CREC] = std::make_unique<ConvertCREC>();
converters[recREFR ] = std::unique_ptr<Converter>(new ConvertREFR()); converters[recREFR ] = std::make_unique<ConvertREFR>();
converters[recPCDT ] = std::unique_ptr<Converter>(new ConvertPCDT()); converters[recPCDT ] = std::make_unique<ConvertPCDT>();
converters[recFMAP ] = std::unique_ptr<Converter>(new ConvertFMAP()); converters[recFMAP ] = std::make_unique<ConvertFMAP>();
converters[recKLST ] = std::unique_ptr<Converter>(new ConvertKLST()); converters[recKLST ] = std::make_unique<ConvertKLST>();
converters[recSTLN ] = std::unique_ptr<Converter>(new ConvertSTLN()); converters[recSTLN ] = std::make_unique<ConvertSTLN>();
converters[recGAME ] = std::unique_ptr<Converter>(new ConvertGAME()); converters[recGAME ] = std::make_unique<ConvertGAME>();
converters[ESM::REC_CELL] = std::unique_ptr<Converter>(new ConvertCell()); converters[ESM::REC_CELL] = std::make_unique<ConvertCell>();
converters[ESM::REC_ALCH] = std::unique_ptr<Converter>(new DefaultConverter<ESM::Potion>()); converters[ESM::REC_ALCH] = std::make_unique<DefaultConverter<ESM::Potion>>();
converters[ESM::REC_CLAS] = std::unique_ptr<Converter>(new ConvertClass()); converters[ESM::REC_CLAS] = std::make_unique<ConvertClass>();
converters[ESM::REC_SPEL] = std::unique_ptr<Converter>(new DefaultConverter<ESM::Spell>()); converters[ESM::REC_SPEL] = std::make_unique<DefaultConverter<ESM::Spell>>();
converters[ESM::REC_ARMO] = std::unique_ptr<Converter>(new DefaultConverter<ESM::Armor>()); converters[ESM::REC_ARMO] = std::make_unique<DefaultConverter<ESM::Armor>>();
converters[ESM::REC_WEAP] = std::unique_ptr<Converter>(new DefaultConverter<ESM::Weapon>()); converters[ESM::REC_WEAP] = std::make_unique<DefaultConverter<ESM::Weapon>>();
converters[ESM::REC_CLOT] = std::unique_ptr<Converter>(new DefaultConverter<ESM::Clothing>()); converters[ESM::REC_CLOT] = std::make_unique<DefaultConverter<ESM::Clothing>>();
converters[ESM::REC_ENCH] = std::unique_ptr<Converter>(new DefaultConverter<ESM::Enchantment>()); converters[ESM::REC_ENCH] = std::make_unique<DefaultConverter<ESM::Enchantment>>();
converters[ESM::REC_WEAP] = std::unique_ptr<Converter>(new DefaultConverter<ESM::Weapon>()); converters[ESM::REC_WEAP] = std::make_unique<DefaultConverter<ESM::Weapon>>();
converters[ESM::REC_LEVC] = std::unique_ptr<Converter>(new DefaultConverter<ESM::CreatureLevList>()); converters[ESM::REC_LEVC] = std::make_unique<DefaultConverter<ESM::CreatureLevList>>();
converters[ESM::REC_LEVI] = std::unique_ptr<Converter>(new DefaultConverter<ESM::ItemLevList>()); converters[ESM::REC_LEVI] = std::make_unique<DefaultConverter<ESM::ItemLevList>>();
converters[ESM::REC_CNTC] = std::unique_ptr<Converter>(new ConvertCNTC()); converters[ESM::REC_CNTC] = std::make_unique<ConvertCNTC>();
converters[ESM::REC_FACT] = std::unique_ptr<Converter>(new ConvertFACT()); converters[ESM::REC_FACT] = std::make_unique<ConvertFACT>();
converters[ESM::REC_INFO] = std::unique_ptr<Converter>(new ConvertINFO()); converters[ESM::REC_INFO] = std::make_unique<ConvertINFO>();
converters[ESM::REC_DIAL] = std::unique_ptr<Converter>(new ConvertDIAL()); converters[ESM::REC_DIAL] = std::make_unique<ConvertDIAL>();
converters[ESM::REC_QUES] = std::unique_ptr<Converter>(new ConvertQUES()); converters[ESM::REC_QUES] = std::make_unique<ConvertQUES>();
converters[recJOUR ] = std::unique_ptr<Converter>(new ConvertJOUR()); converters[recJOUR ] = std::make_unique<ConvertJOUR>();
converters[ESM::REC_SCPT] = std::unique_ptr<Converter>(new ConvertSCPT()); converters[ESM::REC_SCPT] = std::make_unique<ConvertSCPT>();
converters[ESM::REC_PROJ] = std::unique_ptr<Converter>(new ConvertPROJ()); converters[ESM::REC_PROJ] = std::make_unique<ConvertPROJ>();
converters[recSPLM] = std::unique_ptr<Converter>(new ConvertSPLM()); converters[recSPLM] = std::make_unique<ConvertSPLM>();
// TODO: // TODO:
// - REGN (weather in certain regions?) // - REGN (weather in certain regions?)

View file

@ -116,7 +116,7 @@ void CSMDoc::Document::addOptionalGmst (const ESM::GameSetting& gmst)
{ {
if (getData().getGmsts().searchId (gmst.mId)==-1) if (getData().getGmsts().searchId (gmst.mId)==-1)
{ {
std::unique_ptr<CSMWorld::Record<ESM::GameSetting> > record(new CSMWorld::Record<ESM::GameSetting>); auto record = std::make_unique<CSMWorld::Record<ESM::GameSetting>>();
record->mBase = gmst; record->mBase = gmst;
record->mState = CSMWorld::RecordBase::State_BaseOnly; record->mState = CSMWorld::RecordBase::State_BaseOnly;
getData().getGmsts().appendRecord (std::move(record)); 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) if (getData().getGlobals().searchId (global.mId)==-1)
{ {
std::unique_ptr<CSMWorld::Record<ESM::Global> > record(new CSMWorld::Record<ESM::Global>); auto record = std::make_unique<CSMWorld::Record<ESM::Global>>();
record->mBase = global; record->mBase = global;
record->mState = CSMWorld::RecordBase::State_BaseOnly; record->mState = CSMWorld::RecordBase::State_BaseOnly;
getData().getGlobals().appendRecord (std::move(record)); 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) if (getData().getMagicEffects().searchId (magicEffect.mId)==-1)
{ {
std::unique_ptr<CSMWorld::Record<ESM::MagicEffect> > record(new CSMWorld::Record<ESM::MagicEffect>); auto record = std::make_unique<CSMWorld::Record<ESM::MagicEffect>>();
record->mBase = magicEffect; record->mBase = magicEffect;
record->mState = CSMWorld::RecordBase::State_BaseOnly; record->mState = CSMWorld::RecordBase::State_BaseOnly;
getData().getMagicEffects().appendRecord (std::move(record)); getData().getMagicEffects().appendRecord (std::move(record));

View file

@ -579,7 +579,7 @@ bool CSMFilter::Parser::parse (const std::string& filter, bool allowPredefined)
else else
{ {
// Empty filter string equals to filter "true". // Empty filter string equals to filter "true".
mFilter.reset (new BooleanNode (true)); mFilter = std::make_shared<BooleanNode>(true);
} }
return true; return true;

View file

@ -228,7 +228,7 @@ namespace CSMWorld
} }
// Create the actor data // Create the actor data
data.reset(new ActorData()); data = std::make_shared<ActorData>();
setupActor(id, data); setupActor(id, data);
mCachedActors.insert(id, data); mCachedActors.insert(id, data);
return data; return data;
@ -431,7 +431,7 @@ namespace CSMWorld
if (data) return data; if (data) return data;
// Create the race data // Create the race data
data.reset(new RaceData()); data = std::make_shared<RaceData>();
setupRace(id, data); setupRace(id, data);
mCachedRaces.insert(id, data); mCachedRaces.insert(id, data);
return data; return data;

View file

@ -249,12 +249,13 @@ namespace CSMWorld
int Collection<ESXRecordT, IdAccessorT>::cloneRecordImp(const std::string& origin, int Collection<ESXRecordT, IdAccessorT>::cloneRecordImp(const std::string& origin,
const std::string& destination, UniversalId::Type type) const std::string& destination, UniversalId::Type type)
{ {
std::unique_ptr<Record<ESXRecordT> > copy(new Record<ESXRecordT>); auto copy = std::make_unique<Record<ESXRecordT>>();
copy->mModified = getRecord(origin).get(); copy->mModified = getRecord(origin).get();
copy->mState = RecordBase::State_ModifiedOnly; copy->mState = RecordBase::State_ModifiedOnly;
IdAccessorT().setId(copy->get(), destination); IdAccessorT().setId(copy->get(), destination);
if (type == UniversalId::Type_Reference) { if (type == UniversalId::Type_Reference)
{
CSMWorld::CellRef* ptr = (CSMWorld::CellRef*) &copy->mModified; CSMWorld::CellRef* ptr = (CSMWorld::CellRef*) &copy->mModified;
ptr->mRefNum.mIndex = 0; ptr->mRefNum.mIndex = 0;
} }
@ -338,7 +339,7 @@ namespace CSMWorld
if (iter==mIndex.end()) if (iter==mIndex.end())
{ {
std::unique_ptr<Record<ESXRecordT> > record2(new Record<ESXRecordT>); auto record2 = std::make_unique<Record<ESXRecordT>>();
record2->mState = Record<ESXRecordT>::State_ModifiedOnly; record2->mState = Record<ESXRecordT>::State_ModifiedOnly;
record2->mModified = record; record2->mModified = record;
@ -469,7 +470,7 @@ namespace CSMWorld
IdAccessorT().setId(record, id); IdAccessorT().setId(record, id);
record.blank(); record.blank();
std::unique_ptr<Record<ESXRecordT> > record2(new Record<ESXRecordT>); auto record2 = std::make_unique<Record<ESXRecordT>>();
record2->mState = Record<ESXRecordT>::State_ModifiedOnly; record2->mState = Record<ESXRecordT>::State_ModifiedOnly;
record2->mModified = record; record2->mModified = record;

View file

@ -170,14 +170,13 @@ void CSMWorld::CommandDispatcher::executeModify (QAbstractItemModel *model, cons
if (cellId.find ('#')!=std::string::npos) if (cellId.find ('#')!=std::string::npos)
{ {
// Need to recalculate the cell // Need to recalculate the cell
modifyCell.reset (new UpdateCellCommand (model2, row)); modifyCell = std::make_unique<UpdateCellCommand>(model2, row);
} }
} }
} }
} }
std::unique_ptr<CSMWorld::ModifyCommand> modifyData ( auto modifyData = std::make_unique<CSMWorld::ModifyCommand>(*model, index, new_);
new CSMWorld::ModifyCommand (*model, index, new_));
if (modifyCell.get()) if (modifyCell.get())
{ {

View file

@ -70,11 +70,11 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, bool fsStrict, const Files::Pat
mReader (nullptr), mDialogue (nullptr), mReaderIndex(1), mReader (nullptr), mDialogue (nullptr), mReaderIndex(1),
mFsStrict(fsStrict), mDataPaths(dataPaths), mArchives(archives) mFsStrict(fsStrict), mDataPaths(dataPaths), mArchives(archives)
{ {
mVFS.reset(new VFS::Manager(mFsStrict)); mVFS = std::make_unique<VFS::Manager>(mFsStrict);
VFS::registerArchives(mVFS.get(), Files::Collections(mDataPaths, !mFsStrict), mArchives, true); VFS::registerArchives(mVFS.get(), Files::Collections(mDataPaths, !mFsStrict), mArchives, true);
mResourcesManager.setVFS(mVFS.get()); mResourcesManager.setVFS(mVFS.get());
mResourceSystem.reset(new Resource::ResourceSystem(mVFS.get())); mResourceSystem = std::make_unique<Resource::ResourceSystem>(mVFS.get());
Shader::ShaderManager::DefineMap defines = mResourceSystem->getSceneManager()->getShaderManager().getGlobalDefines(); Shader::ShaderManager::DefineMap defines = mResourceSystem->getSceneManager()->getShaderManager().getGlobalDefines();
Shader::ShaderManager::DefineMap shadowDefines = SceneUtil::ShadowManager::getShadowsDisabledDefines(); 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); UniversalId::Type_Video);
addModel (new IdTable (&mMetaData), UniversalId::Type_MetaData); addModel (new IdTable (&mMetaData), UniversalId::Type_MetaData);
mActorAdapter.reset(new ActorAdapter(*this)); mActorAdapter = std::make_unique<ActorAdapter>(*this);
mRefLoadCache.clear(); // clear here rather than startLoading() and continueLoading() for multiple content files mRefLoadCache.clear(); // clear here rather than startLoading() and continueLoading() for multiple content files
} }
@ -963,7 +963,7 @@ int CSMWorld::Data::getTotalRecords (const std::vector<boost::filesystem::path>&
{ {
int records = 0; int records = 0;
std::unique_ptr<ESM::ESMReader> reader = std::unique_ptr<ESM::ESMReader>(new ESM::ESMReader); std::unique_ptr<ESM::ESMReader> reader = std::make_unique<ESM::ESMReader>();
for (unsigned int i = 0; i < files.size(); ++i) for (unsigned int i = 0; i < files.size(); ++i)
{ {
@ -1032,7 +1032,7 @@ void CSMWorld::Data::loadFallbackEntries()
ESM::Static newMarker; ESM::Static newMarker;
newMarker.mId = marker.first; newMarker.mId = marker.first;
newMarker.mModel = marker.second; newMarker.mModel = marker.second;
std::unique_ptr<CSMWorld::Record<ESM::Static> > record(new CSMWorld::Record<ESM::Static>); auto record = std::make_unique<CSMWorld::Record<ESM::Static>>();
record->mBase = newMarker; record->mBase = newMarker;
record->mState = CSMWorld::RecordBase::State_BaseOnly; record->mState = CSMWorld::RecordBase::State_BaseOnly;
mReferenceables.appendRecord (std::move(record), CSMWorld::UniversalId::Type_Static); mReferenceables.appendRecord (std::move(record), CSMWorld::UniversalId::Type_Static);
@ -1046,7 +1046,7 @@ void CSMWorld::Data::loadFallbackEntries()
ESM::Door newMarker; ESM::Door newMarker;
newMarker.mId = marker.first; newMarker.mId = marker.first;
newMarker.mModel = marker.second; newMarker.mModel = marker.second;
std::unique_ptr<CSMWorld::Record<ESM::Door> > record(new CSMWorld::Record<ESM::Door>); auto record = std::make_unique<CSMWorld::Record<ESM::Door>>();
record->mBase = newMarker; record->mBase = newMarker;
record->mState = CSMWorld::RecordBase::State_BaseOnly; record->mState = CSMWorld::RecordBase::State_BaseOnly;
mReferenceables.appendRecord (std::move(record), CSMWorld::UniversalId::Type_Door); mReferenceables.appendRecord (std::move(record), CSMWorld::UniversalId::Type_Door);

View file

@ -32,7 +32,7 @@ namespace CSMWorld
return -1; return -1;
} }
std::unique_ptr<Record<Pathgrid> > baseRecord(new Record<Pathgrid>(this->getRecord(index))); auto baseRecord = std::make_unique<Record<Pathgrid>>(this->getRecord(index));
baseRecord->mState = RecordBase::State_Deleted; baseRecord->mState = RecordBase::State_Deleted;
this->setRecord(index, std::move(baseRecord)); this->setRecord(index, std::move(baseRecord));
return index; return index;

View file

@ -84,7 +84,7 @@ namespace CSMWorld
return -1; return -1;
} }
std::unique_ptr<Record<ESXRecordT> > baseRecord(new Record<ESXRecordT>(this->getRecord(index))); auto baseRecord = std::make_unique<Record<ESXRecordT>>(this->getRecord(index));
baseRecord->mState = RecordBase::State_Deleted; baseRecord->mState = RecordBase::State_Deleted;
this->setRecord(index, std::move(baseRecord)); this->setRecord(index, std::move(baseRecord));
return index; return index;
@ -103,7 +103,7 @@ namespace CSMWorld
if (index==-1) if (index==-1)
{ {
// new record // new record
std::unique_ptr<Record<ESXRecordT> > record2(new Record<ESXRecordT>); auto record2 = std::make_unique<Record<ESXRecordT>>();
record2->mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly; record2->mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly;
(base ? record2->mBase : record2->mModified) = record; (base ? record2->mBase : record2->mModified) = record;
@ -113,8 +113,7 @@ namespace CSMWorld
else else
{ {
// old record // old record
std::unique_ptr<Record<ESXRecordT> > record2( auto record2 = std::make_unique<Record<ESXRecordT>>(Collection<ESXRecordT, IdAccessorT>::getRecord(index));
new Record<ESXRecordT>(Collection<ESXRecordT, IdAccessorT>::getRecord(index)));
if (base) if (base)
record2->mBase = record; record2->mBase = record;
@ -146,8 +145,7 @@ namespace CSMWorld
} }
else else
{ {
std::unique_ptr<Record<ESXRecordT> > record2( auto record2 = std::make_unique<Record<ESXRecordT>>(Collection<ESXRecordT, IdAccessorT>::getRecord(index));
new Record<ESXRecordT>(Collection<ESXRecordT, IdAccessorT>::getRecord(index)));
record2->mState = RecordBase::State_Deleted; record2->mState = RecordBase::State_Deleted;
this->setRecord(index, std::move(record2)); this->setRecord(index, std::move(record2));
} }

View file

@ -77,7 +77,7 @@ void CSMWorld::InfoCollection::load (const Info& record, bool base)
if (index==-1) if (index==-1)
{ {
// new record // new record
std::unique_ptr<Record<Info> > record2(new Record<Info>); auto record2 = std::make_unique<Record<Info>>();
record2->mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly; record2->mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly;
(base ? record2->mBase : record2->mModified) = record; (base ? record2->mBase : record2->mModified) = record;
@ -86,7 +86,7 @@ void CSMWorld::InfoCollection::load (const Info& record, bool base)
else else
{ {
// old record // old record
std::unique_ptr<Record<Info> > record2(new Record<Info>(getRecord(index))); auto record2 = std::make_unique<Record<Info>>(getRecord(index));
if (base) if (base)
record2->mBase = record; record2->mBase = record;
@ -220,7 +220,7 @@ void CSMWorld::InfoCollection::load (ESM::ESMReader& reader, bool base, const ES
} }
else else
{ {
std::unique_ptr<Record<Info> > record(new Record<Info>(getRecord(index))); auto record = std::make_unique<Record<Info>>(getRecord(index));
record->mState = RecordBase::State_Deleted; record->mState = RecordBase::State_Deleted;
setRecord (index, std::move(record)); setRecord (index, std::move(record));
} }
@ -281,7 +281,7 @@ void CSMWorld::InfoCollection::removeDialogueInfos(const std::string& dialogueId
} }
else else
{ {
std::unique_ptr<Record<Info> > record2(new Record<Info>(record)); auto record2 = std::make_unique<Record<Info>>(record);
record2->mState = RecordBase::State_Deleted; record2->mState = RecordBase::State_Deleted;
setRecord(range.first - getRecords().begin(), std::move(record2)); 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) void CSMWorld::InfoCollection::appendBlankRecord (const std::string& id, UniversalId::Type type)
{ {
std::unique_ptr<Record<Info> > record2(new Record<Info>); auto record2 = std::make_unique<Record<Info>>();
record2->mState = Record<Info>::State_ModifiedOnly; record2->mState = Record<Info>::State_ModifiedOnly;
record2->mModified.blank(); record2->mModified.blank();

View file

@ -90,7 +90,7 @@ namespace CSMWorld
template<typename ESXRecordT, typename IdAccessorT> template<typename ESXRecordT, typename IdAccessorT>
void NestedIdCollection<ESXRecordT, IdAccessorT>::addNestedRow(int row, int column, int position) void NestedIdCollection<ESXRecordT, IdAccessorT>::addNestedRow(int row, int column, int position)
{ {
std::unique_ptr<Record<ESXRecordT> > record(new Record<ESXRecordT>); auto record = std::make_unique<Record<ESXRecordT>>();
record->assign(Collection<ESXRecordT, IdAccessorT>::getRecord(row)); record->assign(Collection<ESXRecordT, IdAccessorT>::getRecord(row));
getAdapter(Collection<ESXRecordT, IdAccessorT>::getColumn(column)).addRow(*record, position); getAdapter(Collection<ESXRecordT, IdAccessorT>::getColumn(column)).addRow(*record, position);
@ -101,7 +101,7 @@ namespace CSMWorld
template<typename ESXRecordT, typename IdAccessorT> template<typename ESXRecordT, typename IdAccessorT>
void NestedIdCollection<ESXRecordT, IdAccessorT>::removeNestedRows(int row, int column, int subRow) void NestedIdCollection<ESXRecordT, IdAccessorT>::removeNestedRows(int row, int column, int subRow)
{ {
std::unique_ptr<Record<ESXRecordT> > record(new Record<ESXRecordT>); auto record = std::make_unique<Record<ESXRecordT>>();
record->assign(Collection<ESXRecordT, IdAccessorT>::getRecord(row)); record->assign(Collection<ESXRecordT, IdAccessorT>::getRecord(row));
getAdapter(Collection<ESXRecordT, IdAccessorT>::getColumn(column)).removeRow(*record, subRow); getAdapter(Collection<ESXRecordT, IdAccessorT>::getColumn(column)).removeRow(*record, subRow);
@ -121,7 +121,7 @@ namespace CSMWorld
void NestedIdCollection<ESXRecordT, IdAccessorT>::setNestedData(int row, void NestedIdCollection<ESXRecordT, IdAccessorT>::setNestedData(int row,
int column, const QVariant& data, int subRow, int subColumn) int column, const QVariant& data, int subRow, int subColumn)
{ {
std::unique_ptr<Record<ESXRecordT> > record(new Record<ESXRecordT>); auto record = std::make_unique<Record<ESXRecordT>>();
record->assign(Collection<ESXRecordT, IdAccessorT>::getRecord(row)); record->assign(Collection<ESXRecordT, IdAccessorT>::getRecord(row));
getAdapter(Collection<ESXRecordT, IdAccessorT>::getColumn(column)).setData( getAdapter(Collection<ESXRecordT, IdAccessorT>::getColumn(column)).setData(
@ -142,7 +142,7 @@ namespace CSMWorld
void NestedIdCollection<ESXRecordT, IdAccessorT>::setNestedTable(int row, void NestedIdCollection<ESXRecordT, IdAccessorT>::setNestedTable(int row,
int column, const CSMWorld::NestedTableWrapperBase& nestedTable) int column, const CSMWorld::NestedTableWrapperBase& nestedTable)
{ {
std::unique_ptr<Record<ESXRecordT> > record(new Record<ESXRecordT>); auto record = std::make_unique<Record<ESXRecordT>>();
record->assign(Collection<ESXRecordT, IdAccessorT>::getRecord(row)); record->assign(Collection<ESXRecordT, IdAccessorT>::getRecord(row));
getAdapter(Collection<ESXRecordT, IdAccessorT>::getColumn(column)).setTable( getAdapter(Collection<ESXRecordT, IdAccessorT>::getColumn(column)).setTable(

View file

@ -35,7 +35,7 @@ namespace CSMWorld
void NestedInfoCollection::addNestedRow(int row, int column, int position) void NestedInfoCollection::addNestedRow(int row, int column, int position)
{ {
std::unique_ptr<Record<Info> > record(new Record<Info>); auto record = std::make_unique<Record<Info>>();
record->assign(Collection<Info, IdAccessor<Info> >::getRecord(row)); record->assign(Collection<Info, IdAccessor<Info> >::getRecord(row));
getAdapter(Collection<Info, IdAccessor<Info> >::getColumn(column)).addRow(*record, position); getAdapter(Collection<Info, IdAccessor<Info> >::getColumn(column)).addRow(*record, position);
@ -45,7 +45,7 @@ namespace CSMWorld
void NestedInfoCollection::removeNestedRows(int row, int column, int subRow) void NestedInfoCollection::removeNestedRows(int row, int column, int subRow)
{ {
std::unique_ptr<Record<Info> > record(new Record<Info>); auto record = std::make_unique<Record<Info>>();
record->assign(Collection<Info, IdAccessor<Info> >::getRecord(row)); record->assign(Collection<Info, IdAccessor<Info> >::getRecord(row));
getAdapter(Collection<Info, IdAccessor<Info> >::getColumn(column)).removeRow(*record, subRow); getAdapter(Collection<Info, IdAccessor<Info> >::getColumn(column)).removeRow(*record, subRow);
@ -63,7 +63,7 @@ namespace CSMWorld
void NestedInfoCollection::setNestedData(int row, void NestedInfoCollection::setNestedData(int row,
int column, const QVariant& data, int subRow, int subColumn) int column, const QVariant& data, int subRow, int subColumn)
{ {
std::unique_ptr<Record<Info> > record(new Record<Info>); auto record = std::make_unique<Record<Info>>();
record->assign(Collection<Info, IdAccessor<Info> >::getRecord(row)); record->assign(Collection<Info, IdAccessor<Info> >::getRecord(row));
getAdapter(Collection<Info, IdAccessor<Info> >::getColumn(column)).setData( getAdapter(Collection<Info, IdAccessor<Info> >::getColumn(column)).setData(
@ -82,7 +82,7 @@ namespace CSMWorld
void NestedInfoCollection::setNestedTable(int row, void NestedInfoCollection::setNestedTable(int row,
int column, const CSMWorld::NestedTableWrapperBase& nestedTable) int column, const CSMWorld::NestedTableWrapperBase& nestedTable)
{ {
std::unique_ptr<Record<Info> > record(new Record<Info>); auto record = std::make_unique<Record<Info>>();
record->assign(Collection<Info, IdAccessor<Info> >::getRecord(row)); record->assign(Collection<Info, IdAccessor<Info> >::getRecord(row));
getAdapter(Collection<Info, IdAccessor<Info> >::getColumn(column)).setTable( getAdapter(Collection<Info, IdAccessor<Info> >::getColumn(column)).setTable(

View file

@ -123,7 +123,7 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool
ref.mId = getRecord(index).get().mId; ref.mId = getRecord(index).get().mId;
ref.mIdNum = extractIdNum(ref.mId); ref.mIdNum = extractIdNum(ref.mId);
std::unique_ptr<Record<CellRef> > record(new Record<CellRef>); auto record = std::make_unique<Record<CellRef>>();
// TODO: check whether a base record be moved // TODO: check whether a base record be moved
record->mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly; record->mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly;
(base ? record->mBase : record->mModified) = std::move(ref); (base ? record->mBase : record->mModified) = std::move(ref);
@ -158,7 +158,7 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool
} }
else else
{ {
std::unique_ptr<Record<CellRef> > record(new Record<CellRef>(getRecord(index))); auto record = std::make_unique<Record<CellRef>>(getRecord(index));
record->mState = RecordBase::State_Deleted; record->mState = RecordBase::State_Deleted;
setRecord(index, std::move(record)); setRecord(index, std::move(record));
} }
@ -174,7 +174,7 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool
cache.emplace(refNum, ref.mIdNum); cache.emplace(refNum, ref.mIdNum);
std::unique_ptr<Record<CellRef> > record(new Record<CellRef>); auto record = std::make_unique<Record<CellRef>>();
record->mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly; record->mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly;
(base ? record->mBase : record->mModified) = std::move(ref); (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.mId = getRecord(index).get().mId;
ref.mIdNum = extractIdNum(ref.mId); ref.mIdNum = extractIdNum(ref.mId);
std::unique_ptr<Record<CellRef> > record(new Record<CellRef>(getRecord(index))); auto record = std::make_unique<Record<CellRef>>(getRecord(index));
record->mState = base ? RecordBase::State_BaseOnly : RecordBase::State_Modified; record->mState = base ? RecordBase::State_BaseOnly : RecordBase::State_Modified;
(base ? record->mBase : record->mModified) = std::move(ref); (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) void CSMWorld::RefCollection::appendBlankRecord (const std::string& id, UniversalId::Type type)
{ {
std::unique_ptr<Record<CellRef> > record(new Record<CellRef>); auto record = std::make_unique<Record<CellRef>>();
record->mState = Record<CellRef>::State_ModifiedOnly; record->mState = Record<CellRef>::State_ModifiedOnly;
record->mModified.blank(); record->mModified.blank();
@ -288,15 +288,15 @@ void CSMWorld::RefCollection::cloneRecord (const std::string& origin,
const std::string& destination, const std::string& destination,
const UniversalId::Type type) const UniversalId::Type type)
{ {
std::unique_ptr<Record<CellRef> > copy(new Record<CellRef>); auto copy = std::make_unique<Record<CellRef>>();
copy->mModified = getRecord(origin).get(); copy->mModified = getRecord(origin).get();
copy->mState = RecordBase::State_ModifiedOnly; copy->mState = RecordBase::State_ModifiedOnly;
copy->get().mId = destination; copy->get().mId = destination;
copy->get().mIdNum = extractIdNum(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 int CSMWorld::RefCollection::searchId(std::string_view id) const

View file

@ -130,7 +130,7 @@ namespace CSMWorld
template<typename RecordT> template<typename RecordT>
void RefIdDataContainer<RecordT>::appendRecord (const std::string& id, bool base) void RefIdDataContainer<RecordT>::appendRecord (const std::string& id, bool base)
{ {
std::unique_ptr<Record<RecordT> > record(new Record<RecordT>); auto record = std::make_unique<Record<RecordT>>();
record->mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly; record->mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly;

View file

@ -85,7 +85,7 @@ bool CSVRender::Cell::addObjects (int start, int end)
{ {
std::string id = Misc::StringUtils::lowerCase (collection.getRecord (i).get().mId); std::string id = Misc::StringUtils::lowerCase (collection.getRecord (i).get().mId);
std::unique_ptr<Object> object (new Object (mData, mCellNode, id, false)); auto object = std::make_unique<Object>(mData, mCellNode, id, false);
if (mSubModeElementMask & Mask_Reference) if (mSubModeElementMask & Mask_Reference)
object->setSubMode (mSubMode); object->setSubMode (mSubMode);
@ -128,14 +128,14 @@ void CSVRender::Cell::updateLand()
} }
else else
{ {
mTerrain.reset(new Terrain::TerrainGrid(mCellNode, mCellNode, mTerrain = std::make_unique<Terrain::TerrainGrid>(mCellNode, mCellNode,
mData.getResourceSystem().get(), mTerrainStorage, Mask_Terrain)); mData.getResourceSystem().get(), mTerrainStorage, Mask_Terrain);
} }
mTerrain->loadCell(esmLand.mX, esmLand.mY); mTerrain->loadCell(esmLand.mX, esmLand.mY);
if (!mCellBorder) if (!mCellBorder)
mCellBorder.reset(new CellBorder(mCellNode, mCoordinates)); mCellBorder = std::make_unique<CellBorder>(mCellNode, mCoordinates);
mCellBorder->buildShape(esmLand); mCellBorder->buildShape(esmLand);
@ -186,8 +186,8 @@ CSVRender::Cell::Cell (CSMWorld::Data& data, osg::Group* rootNode, const std::st
updateLand(); updateLand();
mPathgrid.reset(new Pathgrid(mData, mCellNode, mId, mCoordinates)); mPathgrid = std::make_unique<Pathgrid>(mData, mCellNode, mId, mCoordinates);
mCellWater.reset(new CellWater(mData, mCellNode, mId, mCoordinates)); mCellWater = std::make_unique<CellWater>(mData, mCellNode, mId, mCoordinates);
} }
} }
@ -546,7 +546,7 @@ void CSVRender::Cell::setCellArrows (int mask)
if (enable!=(mCellArrows[i].get()!=nullptr)) if (enable!=(mCellArrows[i].get()!=nullptr))
{ {
if (enable) if (enable)
mCellArrows[i].reset (new CellArrow (mCellNode, direction, mCoordinates)); mCellArrows[i] = std::make_unique<CellArrow>(mCellNode, direction, mCoordinates);
else else
mCellArrows[i].reset (nullptr); mCellArrows[i].reset (nullptr);
} }
@ -567,7 +567,7 @@ void CSVRender::Cell::setCellMarker()
} }
if (!isInteriorCell) { if (!isInteriorCell) {
mCellMarker.reset(new CellMarker(mCellNode, mCoordinates, cellExists)); mCellMarker = std::make_unique<CellMarker>(mCellNode, mCoordinates, cellExists);
} }
} }

View file

@ -117,7 +117,7 @@ void CSVRender::Object::update()
{ {
if (recordType == CSMWorld::UniversalId::Type_Npc || recordType == CSMWorld::UniversalId::Type_Creature) 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<Actor>(mReferenceableId, mData);
mActor->update(); mActor->update();
mBaseNode->addChild(mActor->getBaseNode()); mBaseNode->addChild(mActor->getBaseNode());
} }

View file

@ -55,8 +55,8 @@ bool CSVRender::PagedWorldspaceWidget::adjustCells()
{ {
modified = true; modified = true;
std::unique_ptr<Cell> cell (new Cell (mDocument.getData(), mRootNode, auto cell = std::make_unique<Cell>(mDocument.getData(), mRootNode,
iter->first.getId (mWorldspace), deleted)); iter->first.getId (mWorldspace), deleted);
delete iter->second; delete iter->second;
iter->second = cell.release(); iter->second = cell.release();
@ -443,9 +443,7 @@ void CSVRender::PagedWorldspaceWidget::addCellToScene (
bool deleted = index==-1 || bool deleted = index==-1 ||
cells.getRecord (index).mState==CSMWorld::RecordBase::State_Deleted; cells.getRecord (index).mState==CSMWorld::RecordBase::State_Deleted;
std::unique_ptr<Cell> cell ( auto cell = std::make_unique<Cell>(mDocument.getData(), mRootNode, coordinates.getId (mWorldspace), deleted);
new Cell (mDocument.getData(), mRootNode, coordinates.getId (mWorldspace),
deleted));
EditMode *editMode = getEditMode(); EditMode *editMode = getEditMode();
cell->setSubMode (editMode->getSubMode(), editMode->getInteractionMask()); cell->setSubMode (editMode->getSubMode(), editMode->getInteractionMask());

View file

@ -41,7 +41,7 @@ void CSVRender::TerrainShapeMode::activate(CSVWidget::SceneToolbar* toolbar)
{ {
if (!mTerrainShapeSelection) if (!mTerrainShapeSelection)
{ {
mTerrainShapeSelection.reset(new TerrainSelection(mParentNode, &getWorldspaceWidget(), TerrainSelectionType::Shape)); mTerrainShapeSelection = std::make_shared<TerrainSelection>(mParentNode, &getWorldspaceWidget(), TerrainSelectionType::Shape);
} }
if(!mShapeBrushScenetool) if(!mShapeBrushScenetool)
@ -56,7 +56,7 @@ void CSVRender::TerrainShapeMode::activate(CSVWidget::SceneToolbar* toolbar)
} }
if (!mBrushDraw) if (!mBrushDraw)
mBrushDraw.reset(new BrushDraw(mParentNode)); mBrushDraw = std::make_unique<BrushDraw>(mParentNode);
EditMode::activate(toolbar); EditMode::activate(toolbar);
toolbar->addTool (mShapeBrushScenetool); toolbar->addTool (mShapeBrushScenetool);
@ -956,15 +956,15 @@ bool CSVRender::TerrainShapeMode::limitAlteredHeights(const CSMWorld::CellCoordi
// Check for height limits on x-axis // Check for height limits on x-axis
if (leftHeight - thisHeight > limitHeightChange) if (leftHeight - thisHeight > limitHeightChange)
limitedAlteredHeightXAxis.reset(new float(leftHeight - limitHeightChange - (thisHeight - thisAlteredHeight))); limitedAlteredHeightXAxis = std::make_unique<float>(leftHeight - limitHeightChange - (thisHeight - thisAlteredHeight));
else if (leftHeight - thisHeight < -limitHeightChange) else if (leftHeight - thisHeight < -limitHeightChange)
limitedAlteredHeightXAxis.reset(new float(leftHeight + limitHeightChange - (thisHeight - thisAlteredHeight))); limitedAlteredHeightXAxis = std::make_unique<float>(leftHeight + limitHeightChange - (thisHeight - thisAlteredHeight));
// Check for height limits on y-axis // Check for height limits on y-axis
if (upHeight - thisHeight > limitHeightChange) if (upHeight - thisHeight > limitHeightChange)
limitedAlteredHeightYAxis.reset(new float(upHeight - limitHeightChange - (thisHeight - thisAlteredHeight))); limitedAlteredHeightYAxis = std::make_unique<float>(upHeight - limitHeightChange - (thisHeight - thisAlteredHeight));
else if (upHeight - thisHeight < -limitHeightChange) else if (upHeight - thisHeight < -limitHeightChange)
limitedAlteredHeightYAxis.reset(new float(upHeight + limitHeightChange - (thisHeight - thisAlteredHeight))); limitedAlteredHeightYAxis = std::make_unique<float>(upHeight + limitHeightChange - (thisHeight - thisAlteredHeight));
// Limit altered height value based on x or y, whichever is the smallest // Limit altered height value based on x or y, whichever is the smallest
compareAndLimit(cellCoords, inCellX, inCellY, limitedAlteredHeightXAxis.get(), limitedAlteredHeightYAxis.get(), &steepnessIsWithinLimits); 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 // Check for height limits on x-axis
if (rightHeight - thisHeight > limitHeightChange) if (rightHeight - thisHeight > limitHeightChange)
limitedAlteredHeightXAxis.reset(new float(rightHeight - limitHeightChange - (thisHeight - thisAlteredHeight))); limitedAlteredHeightXAxis = std::make_unique<float>(rightHeight - limitHeightChange - (thisHeight - thisAlteredHeight));
else if (rightHeight - thisHeight < -limitHeightChange) else if (rightHeight - thisHeight < -limitHeightChange)
limitedAlteredHeightXAxis.reset(new float(rightHeight + limitHeightChange - (thisHeight - thisAlteredHeight))); limitedAlteredHeightXAxis = std::make_unique<float>(rightHeight + limitHeightChange - (thisHeight - thisAlteredHeight));
// Check for height limits on y-axis // Check for height limits on y-axis
if (downHeight - thisHeight > limitHeightChange) if (downHeight - thisHeight > limitHeightChange)
limitedAlteredHeightYAxis.reset(new float(downHeight - limitHeightChange - (thisHeight - thisAlteredHeight))); limitedAlteredHeightYAxis = std::make_unique<float>(downHeight - limitHeightChange - (thisHeight - thisAlteredHeight));
else if (downHeight - thisHeight < -limitHeightChange) else if (downHeight - thisHeight < -limitHeightChange)
limitedAlteredHeightYAxis.reset(new float(downHeight + limitHeightChange - (thisHeight - thisAlteredHeight))); limitedAlteredHeightYAxis = std::make_unique<float>(downHeight + limitHeightChange - (thisHeight - thisAlteredHeight));
// Limit altered height value based on x or y, whichever is the smallest // Limit altered height value based on x or y, whichever is the smallest
compareAndLimit(cellCoords, inCellX, inCellY, limitedAlteredHeightXAxis.get(), limitedAlteredHeightYAxis.get(), &steepnessIsWithinLimits); 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) if (mode=="Create cell and land, then edit" && useTool)
{ {
std::unique_ptr<CSMWorld::CreateCommand> createCommand ( auto createCommand = std::make_unique<CSMWorld::CreateCommand>(cellTable, cellId);
new CSMWorld::CreateCommand (cellTable, cellId));
int parentIndex = cellTable.findColumnIndex (CSMWorld::Columns::ColumnId_Cell); int parentIndex = cellTable.findColumnIndex (CSMWorld::Columns::ColumnId_Cell);
int index = cellTable.findNestedColumnIndex (parentIndex, CSMWorld::Columns::ColumnId_Interior); int index = cellTable.findNestedColumnIndex (parentIndex, CSMWorld::Columns::ColumnId_Interior);
createCommand->addNestedValue (parentIndex, index, false); createCommand->addNestedValue (parentIndex, index, false);

View file

@ -65,11 +65,11 @@ void CSVRender::TerrainTextureMode::activate(CSVWidget::SceneToolbar* toolbar)
if (!mTerrainTextureSelection) if (!mTerrainTextureSelection)
{ {
mTerrainTextureSelection.reset(new TerrainSelection(mParentNode, &getWorldspaceWidget(), TerrainSelectionType::Texture)); mTerrainTextureSelection = std::make_shared<TerrainSelection>(mParentNode, &getWorldspaceWidget(), TerrainSelectionType::Texture);
} }
if (!mBrushDraw) if (!mBrushDraw)
mBrushDraw.reset(new BrushDraw(mParentNode, true)); mBrushDraw = std::make_unique<BrushDraw>(mParentNode, true);
EditMode::activate(toolbar); EditMode::activate(toolbar);
toolbar->addTool (mTextureBrushScenetool); toolbar->addTool (mTextureBrushScenetool);
@ -662,8 +662,7 @@ bool CSVRender::TerrainTextureMode::allowLandTextureEditing(std::string cellId)
if (mode=="Create cell and land, then edit") if (mode=="Create cell and land, then edit")
{ {
std::unique_ptr<CSMWorld::CreateCommand> createCommand ( auto createCommand = std::make_unique<CSMWorld::CreateCommand>(cellTable, cellId);
new CSMWorld::CreateCommand (cellTable, cellId));
int parentIndex = cellTable.findColumnIndex (CSMWorld::Columns::ColumnId_Cell); int parentIndex = cellTable.findColumnIndex (CSMWorld::Columns::ColumnId_Cell);
int index = cellTable.findNestedColumnIndex (parentIndex, CSMWorld::Columns::ColumnId_Interior); int index = cellTable.findNestedColumnIndex (parentIndex, CSMWorld::Columns::ColumnId_Interior);
createCommand->addNestedValue (parentIndex, index, false); createCommand->addNestedValue (parentIndex, index, false);

View file

@ -56,7 +56,7 @@ CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget (const std::string&
update(); update();
mCell.reset (new Cell (document.getData(), mRootNode, mCellId)); mCell = std::make_unique<Cell>(document.getData(), mRootNode, mCellId);
} }
void CSVRender::UnpagedWorldspaceWidget::cellDataChanged (const QModelIndex& topLeft, void CSVRender::UnpagedWorldspaceWidget::cellDataChanged (const QModelIndex& topLeft,
@ -105,7 +105,7 @@ bool CSVRender::UnpagedWorldspaceWidget::handleDrop (const std::vector<CSMWorld:
mCellId = universalIdData.begin()->getId(); mCellId = universalIdData.begin()->getId();
mCell.reset (new Cell (getDocument().getData(), mRootNode, mCellId)); mCell = std::make_unique<Cell>(getDocument().getData(), mRootNode, mCellId);
mCamPositionSet = false; mCamPositionSet = false;
mOrbitCamControl->reset(); mOrbitCamControl->reset();

View file

@ -96,7 +96,7 @@ namespace CSVWorld
Creator *CreatorFactory<CreatorT, scope>::makeCreator (CSMDoc::Document& document, Creator *CreatorFactory<CreatorT, scope>::makeCreator (CSMDoc::Document& document,
const CSMWorld::UniversalId& id) const const CSMWorld::UniversalId& id) const
{ {
std::unique_ptr<CreatorT> creator (new CreatorT (document.getData(), document.getUndoStack(), id)); auto creator = std::make_unique<CreatorT>(document.getData(), document.getUndoStack(), id);
creator->setScope (scope); creator->setScope (scope);

View file

@ -133,7 +133,7 @@ void CSVWorld::DialogueDelegateDispatcherProxy::editorDataCommited()
void CSVWorld::DialogueDelegateDispatcherProxy::setIndex(const QModelIndex& index) void CSVWorld::DialogueDelegateDispatcherProxy::setIndex(const QModelIndex& index)
{ {
mIndexWrapper.reset(new refWrapper(index)); mIndexWrapper = std::make_unique<refWrapper>(index);
} }
QWidget* CSVWorld::DialogueDelegateDispatcherProxy::getEditor() const QWidget* CSVWorld::DialogueDelegateDispatcherProxy::getEditor() const

View file

@ -238,13 +238,13 @@ void CSVWorld::GenericCreator::create()
if (mCloneMode) if (mCloneMode)
{ {
command.reset (new CSMWorld::CloneCommand ( command = std::make_unique<CSMWorld::CloneCommand>(
dynamic_cast<CSMWorld::IdTable&> (*mData.getTableModel(mListId)), mClonedId, id, mClonedType)); dynamic_cast<CSMWorld::IdTable&> (*mData.getTableModel(mListId)), mClonedId, id, mClonedType);
} }
else else
{ {
command.reset (new CSMWorld::CreateCommand ( command = std::make_unique<CSMWorld::CreateCommand>(
dynamic_cast<CSMWorld::IdTable&> (*mData.getTableModel (mListId)), id)); dynamic_cast<CSMWorld::IdTable&> (*mData.getTableModel (mListId)), id);
} }

View file

@ -213,8 +213,7 @@ int runApplication(int argc, char *argv[])
osg::setNotifyHandler(new OSGLogHandler()); osg::setNotifyHandler(new OSGLogHandler());
Files::ConfigurationManager cfgMgr; Files::ConfigurationManager cfgMgr;
std::unique_ptr<OMW::Engine> engine; std::unique_ptr<OMW::Engine> engine = std::make_unique<OMW::Engine>(cfgMgr);
engine.reset(new OMW::Engine(cfgMgr));
if (parseOptions(argc, argv, *engine, cfgMgr)) if (parseOptions(argc, argv, *engine, cfgMgr))
{ {

View file

@ -119,12 +119,12 @@ namespace MWClass
auto& prng = MWBase::Environment::get().getWorld()->getPrng(); auto& prng = MWBase::Environment::get().getWorld()->getPrng();
const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfActivator", prng); const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfActivator", prng);
std::unique_ptr<MWWorld::Action> action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::FailedAction>("#{sWerewolfRefusal}");
if(sound) action->setSound(sound->mId); if(sound) action->setSound(sound->mId);
return action; return action;
} }
return std::unique_ptr<MWWorld::Action>(new MWWorld::NullAction); return std::make_unique<MWWorld::NullAction>();
} }

View file

@ -110,7 +110,7 @@ namespace MWClass
std::unique_ptr<MWWorld::Action> Apparatus::use (const MWWorld::Ptr& ptr, bool force) const std::unique_ptr<MWWorld::Action> Apparatus::use (const MWWorld::Ptr& ptr, bool force) const
{ {
return std::unique_ptr<MWWorld::Action>(new MWWorld::ActionAlchemy(force)); return std::make_unique<MWWorld::ActionAlchemy>(force);
} }
MWWorld::Ptr Apparatus::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const MWWorld::Ptr Apparatus::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const

View file

@ -336,7 +336,7 @@ namespace MWClass
std::unique_ptr<MWWorld::Action> Armor::use (const MWWorld::Ptr& ptr, bool force) const std::unique_ptr<MWWorld::Action> Armor::use (const MWWorld::Ptr& ptr, bool force) const
{ {
std::unique_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr, force)); std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::ActionEquip>(ptr, force);
action->setSound(getUpSoundId(ptr)); action->setSound(getUpSoundId(ptr));

View file

@ -63,13 +63,13 @@ namespace MWClass
auto& prng = MWBase::Environment::get().getWorld()->getPrng(); auto& prng = MWBase::Environment::get().getWorld()->getPrng();
const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfItem", prng); const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfItem", prng);
std::unique_ptr<MWWorld::Action> action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::FailedAction>("#{sWerewolfRefusal}");
if(sound) action->setSound(sound->mId); if(sound) action->setSound(sound->mId);
return action; return action;
} }
return std::unique_ptr<MWWorld::Action>(new MWWorld::ActionRead(ptr)); return std::make_unique<MWWorld::ActionRead>(ptr);
} }
std::string Book::getScript (const MWWorld::ConstPtr& ptr) const std::string Book::getScript (const MWWorld::ConstPtr& ptr) const
@ -151,7 +151,7 @@ namespace MWClass
std::unique_ptr<MWWorld::Action> Book::use (const MWWorld::Ptr& ptr, bool force) const std::unique_ptr<MWWorld::Action> Book::use (const MWWorld::Ptr& ptr, bool force) const
{ {
return std::unique_ptr<MWWorld::Action>(new MWWorld::ActionRead(ptr)); return std::make_unique<MWWorld::ActionRead>(ptr);
} }
MWWorld::Ptr Book::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const MWWorld::Ptr Book::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const

View file

@ -230,7 +230,7 @@ namespace MWClass
std::unique_ptr<MWWorld::Action> Clothing::use (const MWWorld::Ptr& ptr, bool force) const std::unique_ptr<MWWorld::Action> Clothing::use (const MWWorld::Ptr& ptr, bool force) const
{ {
std::unique_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr, force)); std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::ActionEquip>(ptr, force);
action->setSound(getUpSoundId(ptr)); action->setSound(getUpSoundId(ptr));

View file

@ -135,7 +135,7 @@ namespace MWClass
const MWWorld::Ptr& actor) const const MWWorld::Ptr& actor) const
{ {
if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory)) if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
return std::unique_ptr<MWWorld::Action> (new MWWorld::NullAction ()); return std::make_unique<MWWorld::NullAction>();
if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf())
{ {
@ -143,7 +143,7 @@ namespace MWClass
auto& prng = MWBase::Environment::get().getWorld()->getPrng(); auto& prng = MWBase::Environment::get().getWorld()->getPrng();
const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfContainer", prng); const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfContainer", prng);
std::unique_ptr<MWWorld::Action> action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::FailedAction>("#{sWerewolfRefusal}");
if(sound) action->setSound(sound->mId); if(sound) action->setSound(sound->mId);
return action; return action;
@ -191,24 +191,22 @@ namespace MWClass
{ {
if (canBeHarvested(ptr)) if (canBeHarvested(ptr))
{ {
std::unique_ptr<MWWorld::Action> action (new MWWorld::ActionHarvest(ptr)); return std::make_unique<MWWorld::ActionHarvest>(ptr);
return action;
} }
std::unique_ptr<MWWorld::Action> action (new MWWorld::ActionOpen(ptr)); return std::make_unique<MWWorld::ActionOpen>(ptr);
return action;
} }
else else
{ {
// Activate trap // Activate trap
std::unique_ptr<MWWorld::Action> action(new MWWorld::ActionTrap(ptr.getCellRef().getTrap(), ptr)); std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::ActionTrap>(ptr.getCellRef().getTrap(), ptr);
action->setSound(trapActivationSound); action->setSound(trapActivationSound);
return action; return action;
} }
} }
else else
{ {
std::unique_ptr<MWWorld::Action> action(new MWWorld::FailedAction(std::string(), ptr)); std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::FailedAction>(std::string(), ptr);
action->setSound(lockedSound); action->setSound(lockedSound);
return action; return action;
} }

View file

@ -439,7 +439,7 @@ namespace MWClass
auto& prng = MWBase::Environment::get().getWorld()->getPrng(); auto& prng = MWBase::Environment::get().getWorld()->getPrng();
const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfCreature", prng); const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfCreature", prng);
std::unique_ptr<MWWorld::Action> action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::FailedAction>("#{sWerewolfRefusal}");
if(sound) action->setSound(sound->mId); if(sound) action->setSound(sound->mId);
return action; return action;
@ -453,20 +453,20 @@ namespace MWClass
// by default user can loot friendly actors during death animation // by default user can loot friendly actors during death animation
if (canLoot && !stats.getAiSequence().isInCombat()) if (canLoot && !stats.getAiSequence().isInCombat())
return std::unique_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr)); return std::make_unique<MWWorld::ActionOpen>(ptr);
// otherwise wait until death animation // otherwise wait until death animation
if(stats.isDeathAnimationFinished()) if(stats.isDeathAnimationFinished())
return std::unique_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr)); return std::make_unique<MWWorld::ActionOpen>(ptr);
} }
else if (!stats.getAiSequence().isInCombat() && !stats.getKnockedDown()) else if (!stats.getAiSequence().isInCombat() && !stats.getKnockedDown())
return std::unique_ptr<MWWorld::Action>(new MWWorld::ActionTalk(ptr)); return std::make_unique<MWWorld::ActionTalk>(ptr);
// Tribunal and some mod companions oddly enough must use open action as fallback // Tribunal and some mod companions oddly enough must use open action as fallback
if (!getScript(ptr).empty() && ptr.getRefData().getLocals().getIntVar(getScript(ptr), "companion")) if (!getScript(ptr).empty() && ptr.getRefData().getLocals().getIntVar(getScript(ptr), "companion"))
return std::unique_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr)); return std::make_unique<MWWorld::ActionOpen>(ptr);
return std::unique_ptr<MWWorld::Action>(new MWWorld::FailedAction("")); return std::make_unique<MWWorld::FailedAction>();
} }
MWWorld::ContainerStore& Creature::getContainerStore (const MWWorld::Ptr& ptr) const MWWorld::ContainerStore& Creature::getContainerStore (const MWWorld::Ptr& ptr) const
@ -763,7 +763,7 @@ namespace MWClass
else else
{ {
// Create a CustomData, but don't fill it from ESM records (not needed) // Create a CustomData, but don't fill it from ESM records (not needed)
std::unique_ptr<CreatureCustomData> data (new CreatureCustomData); auto data = std::make_unique<CreatureCustomData>();
if (hasInventoryStore(ptr)) if (hasInventoryStore(ptr))
data->mContainerStore = std::make_unique<MWWorld::InventoryStore>(); data->mContainerStore = std::make_unique<MWWorld::InventoryStore>();

View file

@ -131,7 +131,7 @@ namespace MWClass
// Make such activation a no-op for now, like how it is in the vanilla game. // Make such activation a no-op for now, like how it is in the vanilla game.
if (actor != MWMechanics::getPlayer() && ptr.getCellRef().getTeleport()) if (actor != MWMechanics::getPlayer() && ptr.getCellRef().getTeleport())
{ {
std::unique_ptr<MWWorld::Action> action(new MWWorld::FailedAction(std::string(), ptr)); std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::FailedAction>(std::string(), ptr);
action->setSound(lockedSound); action->setSound(lockedSound);
return action; return action;
} }
@ -182,7 +182,7 @@ namespace MWClass
if(isTrapped) if(isTrapped)
{ {
// Trap activation // Trap activation
std::unique_ptr<MWWorld::Action> action(new MWWorld::ActionTrap(ptr.getCellRef().getTrap(), ptr)); std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::ActionTrap>(ptr.getCellRef().getTrap(), ptr);
action->setSound(trapActivationSound); action->setSound(trapActivationSound);
return action; return action;
} }
@ -192,12 +192,11 @@ namespace MWClass
if (actor == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getDistanceToFacedObject() > MWBase::Environment::get().getWorld()->getMaxActivationDistance()) if (actor == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getDistanceToFacedObject() > MWBase::Environment::get().getWorld()->getMaxActivationDistance())
{ {
// player activated teleport door with telekinesis // player activated teleport door with telekinesis
std::unique_ptr<MWWorld::Action> action(new MWWorld::FailedAction); return std::make_unique<MWWorld::FailedAction>();
return action;
} }
else else
{ {
std::unique_ptr<MWWorld::Action> action(new MWWorld::ActionTeleport (ptr.getCellRef().getDestCell(), ptr.getCellRef().getDoorDest(), true)); std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::ActionTeleport>(ptr.getCellRef().getDestCell(), ptr.getCellRef().getDoorDest(), true);
action->setSound(openSound); action->setSound(openSound);
return action; return action;
} }
@ -205,7 +204,7 @@ namespace MWClass
else else
{ {
// animated door // animated door
std::unique_ptr<MWWorld::Action> action(new MWWorld::ActionDoor(ptr)); std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::ActionDoor>(ptr);
const auto doorState = getDoorState(ptr); const auto doorState = getDoorState(ptr);
bool opening = true; bool opening = true;
float doorRot = ptr.getRefData().getPosition().rot[2] - ptr.getCellRef().getPosition().rot[2]; float doorRot = ptr.getRefData().getPosition().rot[2] - ptr.getCellRef().getPosition().rot[2];
@ -239,7 +238,7 @@ namespace MWClass
else else
{ {
// locked, and we can't open. // locked, and we can't open.
std::unique_ptr<MWWorld::Action> action(new MWWorld::FailedAction(std::string(), ptr)); std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::FailedAction>(std::string(), ptr);
action->setSound(lockedSound); action->setSound(lockedSound);
return action; return action;
} }

View file

@ -74,7 +74,7 @@ namespace MWClass
std::unique_ptr<MWWorld::Action> Ingredient::use (const MWWorld::Ptr& ptr, bool force) const std::unique_ptr<MWWorld::Action> Ingredient::use (const MWWorld::Ptr& ptr, bool force) const
{ {
std::unique_ptr<MWWorld::Action> action (new MWWorld::ActionEat (ptr)); std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::ActionEat>(ptr);
action->setSound ("Swallow"); action->setSound ("Swallow");

View file

@ -89,11 +89,11 @@ namespace MWClass
const MWWorld::Ptr& actor) const const MWWorld::Ptr& actor) const
{ {
if(!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory)) if(!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
return std::unique_ptr<MWWorld::Action>(new MWWorld::NullAction()); return std::make_unique<MWWorld::NullAction>();
MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>(); MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>();
if(!(ref->mBase->mData.mFlags&ESM::Light::Carry)) if(!(ref->mBase->mData.mFlags&ESM::Light::Carry))
return std::unique_ptr<MWWorld::Action>(new MWWorld::FailedAction()); return std::make_unique<MWWorld::FailedAction>();
return defaultItemActivate(ptr, actor); return defaultItemActivate(ptr, actor);
} }
@ -186,7 +186,7 @@ namespace MWClass
std::unique_ptr<MWWorld::Action> Light::use (const MWWorld::Ptr& ptr, bool force) const std::unique_ptr<MWWorld::Action> Light::use (const MWWorld::Ptr& ptr, bool force) const
{ {
std::unique_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr, force)); std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::ActionEquip>(ptr, force);
action->setSound(getUpSoundId(ptr)); action->setSound(getUpSoundId(ptr));

View file

@ -126,7 +126,7 @@ namespace MWClass
std::unique_ptr<MWWorld::Action> Lockpick::use (const MWWorld::Ptr& ptr, bool force) const std::unique_ptr<MWWorld::Action> Lockpick::use (const MWWorld::Ptr& ptr, bool force) const
{ {
std::unique_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr, force)); std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::ActionEquip>(ptr, force);
action->setSound(getUpSoundId(ptr)); action->setSound(getUpSoundId(ptr));

View file

@ -206,9 +206,8 @@ namespace MWClass
std::unique_ptr<MWWorld::Action> Miscellaneous::use (const MWWorld::Ptr& ptr, bool force) const std::unique_ptr<MWWorld::Action> Miscellaneous::use (const MWWorld::Ptr& ptr, bool force) const
{ {
if (ptr.getCellRef().getSoul().empty() || !MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().search(ptr.getCellRef().getSoul())) if (ptr.getCellRef().getSoul().empty() || !MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().search(ptr.getCellRef().getSoul()))
return std::unique_ptr<MWWorld::Action>(new MWWorld::NullAction()); return std::make_unique<MWWorld::NullAction>();
else return std::make_unique<MWWorld::ActionSoulgem>(ptr);
return std::unique_ptr<MWWorld::Action>(new MWWorld::ActionSoulgem(ptr));
} }
bool Miscellaneous::canSell (const MWWorld::ConstPtr& item, int npcServices) const bool Miscellaneous::canSell (const MWWorld::ConstPtr& item, int npcServices) const

View file

@ -865,7 +865,7 @@ namespace MWClass
{ {
// player got activated by another NPC // player got activated by another NPC
if(ptr == MWMechanics::getPlayer()) if(ptr == MWMechanics::getPlayer())
return std::unique_ptr<MWWorld::Action>(new MWWorld::ActionTalk(actor)); return std::make_unique<MWWorld::ActionTalk>(actor);
// Werewolfs can't activate NPCs // Werewolfs can't activate NPCs
if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf())
@ -874,7 +874,7 @@ namespace MWClass
auto& prng = MWBase::Environment::get().getWorld()->getPrng(); auto& prng = MWBase::Environment::get().getWorld()->getPrng();
const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfNPC", prng); const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfNPC", prng);
std::unique_ptr<MWWorld::Action> action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::FailedAction>("#{sWerewolfRefusal}");
if(sound) action->setSound(sound->mId); if(sound) action->setSound(sound->mId);
return action; return action;
@ -888,33 +888,33 @@ namespace MWClass
// by default user can loot friendly actors during death animation // by default user can loot friendly actors during death animation
if (canLoot && !stats.getAiSequence().isInCombat()) if (canLoot && !stats.getAiSequence().isInCombat())
return std::unique_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr)); return std::make_unique<MWWorld::ActionOpen>(ptr);
// otherwise wait until death animation // otherwise wait until death animation
if(stats.isDeathAnimationFinished()) if(stats.isDeathAnimationFinished())
return std::unique_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr)); return std::make_unique<MWWorld::ActionOpen>(ptr);
} }
else if (!stats.getAiSequence().isInCombat()) else if (!stats.getAiSequence().isInCombat())
{ {
if (stats.getKnockedDown() || MWBase::Environment::get().getMechanicsManager()->isSneaking(actor)) if (stats.getKnockedDown() || MWBase::Environment::get().getMechanicsManager()->isSneaking(actor))
return std::unique_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr)); // stealing return std::make_unique<MWWorld::ActionOpen>(ptr); // stealing
// Can't talk to werewolves // Can't talk to werewolves
if (!getNpcStats(ptr).isWerewolf()) if (!getNpcStats(ptr).isWerewolf())
return std::unique_ptr<MWWorld::Action>(new MWWorld::ActionTalk(ptr)); return std::make_unique<MWWorld::ActionTalk>(ptr);
} }
else // In combat else // In combat
{ {
const bool stealingInCombat = Settings::Manager::getBool ("always allow stealing from knocked out actors", "Game"); const bool stealingInCombat = Settings::Manager::getBool ("always allow stealing from knocked out actors", "Game");
if (stealingInCombat && stats.getKnockedDown()) if (stealingInCombat && stats.getKnockedDown())
return std::unique_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr)); // stealing return std::make_unique<MWWorld::ActionOpen>(ptr); // stealing
} }
// Tribunal and some mod companions oddly enough must use open action as fallback // Tribunal and some mod companions oddly enough must use open action as fallback
if (!getScript(ptr).empty() && ptr.getRefData().getLocals().getIntVar(getScript(ptr), "companion")) if (!getScript(ptr).empty() && ptr.getRefData().getLocals().getIntVar(getScript(ptr), "companion"))
return std::unique_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr)); return std::make_unique<MWWorld::ActionOpen>(ptr);
return std::unique_ptr<MWWorld::Action> (new MWWorld::FailedAction("")); return std::make_unique<MWWorld::FailedAction>();
} }
MWWorld::ContainerStore& Npc::getContainerStore (const MWWorld::Ptr& ptr) MWWorld::ContainerStore& Npc::getContainerStore (const MWWorld::Ptr& ptr)

View file

@ -126,7 +126,7 @@ namespace MWClass
std::unique_ptr<MWWorld::Action> Probe::use (const MWWorld::Ptr& ptr, bool force) const std::unique_ptr<MWWorld::Action> Probe::use (const MWWorld::Ptr& ptr, bool force) const
{ {
std::unique_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr, force)); std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::ActionEquip>(ptr, force);
action->setSound(getUpSoundId(ptr)); action->setSound(getUpSoundId(ptr));

View file

@ -134,7 +134,7 @@ namespace MWClass
std::unique_ptr<MWWorld::Action> Repair::use (const MWWorld::Ptr& ptr, bool force) const std::unique_ptr<MWWorld::Action> Repair::use (const MWWorld::Ptr& ptr, bool force) const
{ {
return std::unique_ptr<MWWorld::Action>(new MWWorld::ActionRepair(ptr, force)); return std::make_unique<MWWorld::ActionRepair>(ptr, force);
} }
bool Repair::canSell (const MWWorld::ConstPtr& item, int npcServices) const bool Repair::canSell (const MWWorld::ConstPtr& item, int npcServices) const

View file

@ -301,7 +301,7 @@ namespace MWClass
std::unique_ptr<MWWorld::Action> Weapon::use (const MWWorld::Ptr& ptr, bool force) const std::unique_ptr<MWWorld::Action> Weapon::use (const MWWorld::Ptr& ptr, bool force) const
{ {
std::unique_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr, force)); std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::ActionEquip>(ptr, force);
action->setSound(getUpSoundId(ptr)); action->setSound(getUpSoundId(ptr));

View file

@ -1116,7 +1116,7 @@ public:
if (j == this_->mActiveTextFormats.end ()) if (j == this_->mActiveTextFormats.end ())
{ {
std::unique_ptr<TextFormat> textFormat(new TextFormat (Font, this_)); auto textFormat = std::make_unique<TextFormat>(Font, this_);
textFormat->mTexture = Font->getTextureFont (); textFormat->mTexture = Font->getTextureFont ();

View file

@ -63,11 +63,11 @@ namespace MWGui
, mGuiMode(GM_Inventory) , mGuiMode(GM_Inventory)
, mLastXSize(0) , mLastXSize(0)
, mLastYSize(0) , mLastYSize(0)
, mPreview(new MWRender::InventoryPreview(parent, resourceSystem, MWMechanics::getPlayer())) , mPreview(std::make_unique<MWRender::InventoryPreview>(parent, resourceSystem, MWMechanics::getPlayer()))
, mTrading(false) , mTrading(false)
, mUpdateTimer(0.f) , mUpdateTimer(0.f)
{ {
mPreviewTexture.reset(new osgMyGUI::OSGTexture(mPreview->getTexture(), mPreview->getTextureStateSet())); mPreviewTexture = std::make_unique<osgMyGUI::OSGTexture>(mPreview->getTexture(), mPreview->getTextureStateSet());
mPreview->rebuild(); mPreview->rebuild();
mMainWidget->castType<MyGUI::Window>()->eventWindowChangeCoord += MyGUI::newDelegate(this, &InventoryWindow::onWindowResize); mMainWidget->castType<MyGUI::Window>()->eventWindowChangeCoord += MyGUI::newDelegate(this, &InventoryWindow::onWindowResize);

View file

@ -297,7 +297,7 @@ namespace MWGui
if (!mGuiTexture.get()) if (!mGuiTexture.get())
{ {
mGuiTexture.reset(new osgMyGUI::OSGTexture(mTexture)); mGuiTexture = std::make_unique<osgMyGUI::OSGTexture>(mTexture);
} }
if (!mCopyFramebufferToTextureCallback) if (!mCopyFramebufferToTextureCallback)

View file

@ -596,27 +596,27 @@ namespace MWGui
osg::ref_ptr<osg::Texture2D> texture = mLocalMapRender->getMapTexture(entry.mCellX, entry.mCellY); osg::ref_ptr<osg::Texture2D> texture = mLocalMapRender->getMapTexture(entry.mCellX, entry.mCellY);
if (texture) if (texture)
{ {
entry.mMapTexture.reset(new osgMyGUI::OSGTexture(texture)); entry.mMapTexture = std::make_unique<osgMyGUI::OSGTexture>(texture);
entry.mMapWidget->setRenderItemTexture(entry.mMapTexture.get()); entry.mMapWidget->setRenderItemTexture(entry.mMapTexture.get());
entry.mMapWidget->getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 0.f, 1.f, 1.f)); entry.mMapWidget->getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 0.f, 1.f, 1.f));
needRedraw = true; needRedraw = true;
} }
else else
entry.mMapTexture.reset(new osgMyGUI::OSGTexture("", nullptr)); entry.mMapTexture = std::make_unique<osgMyGUI::OSGTexture>(std::string(), nullptr);
} }
if (!entry.mFogTexture && mFogOfWarToggled && mFogOfWarEnabled) if (!entry.mFogTexture && mFogOfWarToggled && mFogOfWarEnabled)
{ {
osg::ref_ptr<osg::Texture2D> tex = mLocalMapRender->getFogOfWarTexture(entry.mCellX, entry.mCellY); osg::ref_ptr<osg::Texture2D> tex = mLocalMapRender->getFogOfWarTexture(entry.mCellX, entry.mCellY);
if (tex) if (tex)
{ {
entry.mFogTexture.reset(new osgMyGUI::OSGTexture(tex)); entry.mFogTexture = std::make_unique<osgMyGUI::OSGTexture>(tex);
entry.mFogWidget->setRenderItemTexture(entry.mFogTexture.get()); entry.mFogWidget->setRenderItemTexture(entry.mFogTexture.get());
entry.mFogWidget->getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 1.f, 1.f, 0.f)); entry.mFogWidget->getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 1.f, 1.f, 0.f));
} }
else else
{ {
entry.mFogWidget->setImageTexture("black"); entry.mFogWidget->setImageTexture("black");
entry.mFogTexture.reset(new osgMyGUI::OSGTexture("", nullptr)); entry.mFogTexture = std::make_unique<osgMyGUI::OSGTexture>(std::string(), nullptr);
} }
needRedraw = true; needRedraw = true;
} }
@ -1279,11 +1279,11 @@ namespace MWGui
{ {
if (!mGlobalMapTexture.get()) if (!mGlobalMapTexture.get())
{ {
mGlobalMapTexture.reset(new osgMyGUI::OSGTexture(mGlobalMapRender->getBaseTexture())); mGlobalMapTexture = std::make_unique<osgMyGUI::OSGTexture>(mGlobalMapRender->getBaseTexture());
mGlobalMapImage->setRenderItemTexture(mGlobalMapTexture.get()); mGlobalMapImage->setRenderItemTexture(mGlobalMapTexture.get());
mGlobalMapImage->getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 0.f, 1.f, 1.f)); mGlobalMapImage->getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 0.f, 1.f, 1.f));
mGlobalMapOverlayTexture.reset(new osgMyGUI::OSGTexture(mGlobalMapRender->getOverlayTexture())); mGlobalMapOverlayTexture = std::make_unique<osgMyGUI::OSGTexture>(mGlobalMapRender->getOverlayTexture());
mGlobalMapOverlay->setRenderItemTexture(mGlobalMapOverlayTexture.get()); mGlobalMapOverlay->setRenderItemTexture(mGlobalMapOverlayTexture.get());
mGlobalMapOverlay->getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 0.f, 1.f, 1.f)); mGlobalMapOverlay->getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 0.f, 1.f, 1.f));

View file

@ -134,11 +134,11 @@ namespace MWGui
mPreview.reset(nullptr); mPreview.reset(nullptr);
mPreviewTexture.reset(nullptr); mPreviewTexture.reset(nullptr);
mPreview.reset(new MWRender::RaceSelectionPreview(mParent, mResourceSystem)); mPreview = std::make_unique<MWRender::RaceSelectionPreview>(mParent, mResourceSystem);
mPreview->rebuild(); mPreview->rebuild();
mPreview->setAngle (mCurrentAngle); mPreview->setAngle (mCurrentAngle);
mPreviewTexture.reset(new osgMyGUI::OSGTexture(mPreview->getTexture(), mPreview->getTextureStateSet())); mPreviewTexture = std::make_unique<osgMyGUI::OSGTexture>(mPreview->getTexture(), mPreview->getTextureStateSet());
mPreviewImage->setRenderItemTexture(mPreviewTexture.get()); mPreviewImage->setRenderItemTexture(mPreviewTexture.get());
mPreviewImage->getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 0.f, 1.f, 1.f)); mPreviewImage->getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 0.f, 1.f, 1.f));

View file

@ -458,7 +458,7 @@ namespace MWGui
texture->setResizeNonPowerOfTwoHint(false); texture->setResizeNonPowerOfTwoHint(false);
texture->setUnRefImageDataAfterApply(true); texture->setUnRefImageDataAfterApply(true);
mScreenshotTexture.reset(new osgMyGUI::OSGTexture(texture)); mScreenshotTexture = std::make_unique<osgMyGUI::OSGTexture>(texture);
mScreenshot->setRenderItemTexture(mScreenshotTexture.get()); mScreenshot->setRenderItemTexture(mScreenshotTexture.get());
mScreenshot->getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 0.f, 1.f, 1.f)); mScreenshot->getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 0.f, 1.f, 1.f));

View file

@ -18,7 +18,7 @@ namespace MWGui
VideoWidget::VideoWidget() VideoWidget::VideoWidget()
: mVFS(nullptr) : mVFS(nullptr)
{ {
mPlayer.reset(new Video::VideoPlayer()); mPlayer = std::make_unique<Video::VideoPlayer>();
setNeedKeyFocus(true); setNeedKeyFocus(true);
} }
@ -50,7 +50,7 @@ void VideoWidget::playVideo(const std::string &video)
if (!texture) if (!texture)
return; return;
mTexture.reset(new osgMyGUI::OSGTexture(texture)); mTexture = std::make_unique<osgMyGUI::OSGTexture>(texture);
setRenderItemTexture(mTexture.get()); setRenderItemTexture(mTexture.get());
getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 1.f, 1.f, 0.f)); getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 1.f, 1.f, 0.f));

View file

@ -206,7 +206,7 @@ namespace MWGui
MyGUI::LanguageManager::getInstance().eventRequestTag = MyGUI::newDelegate(this, &WindowManager::onRetrieveTag); MyGUI::LanguageManager::getInstance().eventRequestTag = MyGUI::newDelegate(this, &WindowManager::onRetrieveTag);
// Load fonts // Load fonts
mFontLoader.reset(new Gui::FontLoader(encoding, resourceSystem->getVFS(), userDataPath, mScalingFactor)); mFontLoader = std::make_unique<Gui::FontLoader>(encoding, resourceSystem->getVFS(), userDataPath, mScalingFactor);
mFontLoader->loadBitmapFonts(exportFonts); mFontLoader->loadBitmapFonts(exportFonts);
//Register own widgets with MyGUI //Register own widgets with MyGUI
@ -238,7 +238,7 @@ namespace MWGui
WindowManager::loadUserFonts(); WindowManager::loadUserFonts();
bool keyboardNav = Settings::Manager::getBool("keyboard navigation", "GUI"); bool keyboardNav = Settings::Manager::getBool("keyboard navigation", "GUI");
mKeyboardNavigation.reset(new KeyboardNavigation()); mKeyboardNavigation = std::make_unique<KeyboardNavigation>();
mKeyboardNavigation->setEnabled(keyboardNav); mKeyboardNavigation->setEnabled(keyboardNav);
Gui::ImageButton::setDefaultNeedKeyFocus(keyboardNav); Gui::ImageButton::setDefaultNeedKeyFocus(keyboardNav);
@ -288,7 +288,7 @@ namespace MWGui
if (useShaders) if (useShaders)
mGuiPlatform->getRenderManagerPtr()->enableShaders(mResourceSystem->getSceneManager()->getShaderManager()); mGuiPlatform->getRenderManagerPtr()->enableShaders(mResourceSystem->getSceneManager()->getShaderManager());
mStatsWatcher.reset(new StatsWatcher()); mStatsWatcher = std::make_unique<StatsWatcher>();
} }
void WindowManager::loadUserFonts() void WindowManager::loadUserFonts()

View file

@ -46,7 +46,7 @@ namespace MWMechanics
void AiActivate::writeState(ESM::AiSequence::AiSequence &sequence) const void AiActivate::writeState(ESM::AiSequence::AiSequence &sequence) const
{ {
std::unique_ptr<ESM::AiSequence::AiActivate> activate(new ESM::AiSequence::AiActivate()); auto activate = std::make_unique<ESM::AiSequence::AiActivate>();
activate->mTargetId = mObjectId; activate->mTargetId = mObjectId;
activate->mRepeat = getRepeat(); activate->mRepeat = getRepeat();

View file

@ -200,7 +200,7 @@ namespace MWMechanics
} }
else else
{ {
currentAction.reset(new ActionFlee()); currentAction = std::make_unique<ActionFlee>();
actionCooldown = currentAction->getActionCooldown(); actionCooldown = currentAction->getActionCooldown();
} }
@ -300,7 +300,7 @@ namespace MWMechanics
storage.mUseCustomDestination = false; storage.mUseCustomDestination = false;
storage.stopAttack(); storage.stopAttack();
actor.getClass().getCreatureStats(actor).setAttackingOrSpell(false); actor.getClass().getCreatureStats(actor).setAttackingOrSpell(false);
currentAction.reset(new ActionFlee()); currentAction = std::make_unique<ActionFlee>();
actionCooldown = currentAction->getActionCooldown(); actionCooldown = currentAction->getActionCooldown();
storage.startFleeing(); storage.startFleeing();
MWBase::Environment::get().getDialogueManager()->say(actor, "flee"); MWBase::Environment::get().getDialogueManager()->say(actor, "flee");
@ -460,7 +460,7 @@ namespace MWMechanics
void AiCombat::writeState(ESM::AiSequence::AiSequence &sequence) const void AiCombat::writeState(ESM::AiSequence::AiSequence &sequence) const
{ {
std::unique_ptr<ESM::AiSequence::AiCombat> combat(new ESM::AiSequence::AiCombat()); auto combat = std::make_unique<ESM::AiSequence::AiCombat>();
combat->mTargetActorId = mTargetActorId; combat->mTargetActorId = mTargetActorId;
ESM::AiSequence::AiPackageContainer package; ESM::AiSequence::AiPackageContainer package;

View file

@ -148,7 +148,7 @@ namespace MWMechanics
float bestActionRating = 0.f; float bestActionRating = 0.f;
float antiFleeRating = 0.f; float antiFleeRating = 0.f;
// Default to hand-to-hand combat // Default to hand-to-hand combat
std::unique_ptr<Action> bestAction (new ActionWeapon(MWWorld::Ptr())); std::unique_ptr<Action> bestAction = std::make_unique<ActionWeapon>(MWWorld::Ptr());
if (actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) if (actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf())
{ {
bestAction->prepare(actor); bestAction->prepare(actor);
@ -165,7 +165,7 @@ namespace MWMechanics
if (rating > bestActionRating) if (rating > bestActionRating)
{ {
bestActionRating = rating; bestActionRating = rating;
bestAction.reset(new ActionPotion(*it)); bestAction = std::make_unique<ActionPotion>(*it);
antiFleeRating = std::numeric_limits<float>::max(); antiFleeRating = std::numeric_limits<float>::max();
} }
} }
@ -176,7 +176,7 @@ namespace MWMechanics
if (rating > bestActionRating) if (rating > bestActionRating)
{ {
bestActionRating = rating; bestActionRating = rating;
bestAction.reset(new ActionEnchantedItem(it)); bestAction = std::make_unique<ActionEnchantedItem>(it);
antiFleeRating = std::numeric_limits<float>::max(); antiFleeRating = std::numeric_limits<float>::max();
} }
} }
@ -202,7 +202,7 @@ namespace MWMechanics
ammo = bestBolt; ammo = bestBolt;
bestActionRating = rating; bestActionRating = rating;
bestAction.reset(new ActionWeapon(*it, ammo)); bestAction = std::make_unique<ActionWeapon>(*it, ammo);
antiFleeRating = vanillaRateWeaponAndAmmo(*it, ammo, actor, enemy); antiFleeRating = vanillaRateWeaponAndAmmo(*it, ammo, actor, enemy);
} }
} }
@ -214,13 +214,13 @@ namespace MWMechanics
if (rating > bestActionRating) if (rating > bestActionRating)
{ {
bestActionRating = rating; bestActionRating = rating;
bestAction.reset(new ActionSpell(spell->mId)); bestAction = std::make_unique<ActionSpell>(spell->mId);
antiFleeRating = vanillaRateSpell(spell, actor, enemy); antiFleeRating = vanillaRateSpell(spell, actor, enemy);
} }
} }
if (makeFleeDecision(actor, enemy, antiFleeRating)) if (makeFleeDecision(actor, enemy, antiFleeRating))
bestAction.reset(new ActionFlee()); bestAction = std::make_unique<ActionFlee>();
if (bestAction.get()) if (bestAction.get())
bestAction->prepare(actor); bestAction->prepare(actor);

View file

@ -96,7 +96,7 @@ namespace MWMechanics
void AiEscort::writeState(ESM::AiSequence::AiSequence &sequence) const void AiEscort::writeState(ESM::AiSequence::AiSequence &sequence) const
{ {
std::unique_ptr<ESM::AiSequence::AiEscort> escort(new ESM::AiSequence::AiEscort()); auto escort = std::make_unique<ESM::AiSequence::AiEscort>();
escort->mData.mX = mX; escort->mData.mX = mX;
escort->mData.mY = mY; escort->mData.mY = mY;
escort->mData.mZ = mZ; escort->mData.mZ = mZ;

View file

@ -201,7 +201,7 @@ bool AiFollow::isCommanded() const
void AiFollow::writeState(ESM::AiSequence::AiSequence &sequence) const void AiFollow::writeState(ESM::AiSequence::AiSequence &sequence) const
{ {
std::unique_ptr<ESM::AiSequence::AiFollow> follow(new ESM::AiSequence::AiFollow()); auto follow = std::make_unique<ESM::AiSequence::AiFollow>();
follow->mData.mX = mX; follow->mData.mX = mX;
follow->mData.mY = mY; follow->mData.mY = mY;
follow->mData.mZ = mZ; follow->mData.mZ = mZ;

View file

@ -84,7 +84,7 @@ MWWorld::Ptr AiPursue::getTarget() const
void AiPursue::writeState(ESM::AiSequence::AiSequence &sequence) const void AiPursue::writeState(ESM::AiSequence::AiSequence &sequence) const
{ {
std::unique_ptr<ESM::AiSequence::AiPursue> pursue(new ESM::AiSequence::AiPursue()); auto pursue = std::make_unique<ESM::AiSequence::AiPursue>();
pursue->mTargetActorId = mTargetActorId; pursue->mTargetActorId = mTargetActorId;
ESM::AiSequence::AiPackageContainer package; ESM::AiSequence::AiPackageContainer package;

View file

@ -498,41 +498,41 @@ void AiSequence::readState(const ESM::AiSequence::AiSequence &sequence)
{ {
case ESM::AiSequence::Ai_Wander: case ESM::AiSequence::Ai_Wander:
{ {
package.reset(new AiWander(&static_cast<const ESM::AiSequence::AiWander&>(*container.mPackage))); package = std::make_unique<AiWander>(&static_cast<const ESM::AiSequence::AiWander&>(*container.mPackage));
break; break;
} }
case ESM::AiSequence::Ai_Travel: case ESM::AiSequence::Ai_Travel:
{ {
const ESM::AiSequence::AiTravel& source = static_cast<const ESM::AiSequence::AiTravel&>(*container.mPackage); const ESM::AiSequence::AiTravel& source = static_cast<const ESM::AiSequence::AiTravel&>(*container.mPackage);
if (source.mHidden) if (source.mHidden)
package.reset(new AiInternalTravel(&source)); package = std::make_unique<AiInternalTravel>(&source);
else else
package.reset(new AiTravel(&source)); package = std::make_unique<AiTravel>(&source);
break; break;
} }
case ESM::AiSequence::Ai_Escort: case ESM::AiSequence::Ai_Escort:
{ {
package.reset(new AiEscort(&static_cast<const ESM::AiSequence::AiEscort&>(*container.mPackage))); package = std::make_unique<AiEscort>(&static_cast<const ESM::AiSequence::AiEscort&>(*container.mPackage));
break; break;
} }
case ESM::AiSequence::Ai_Follow: case ESM::AiSequence::Ai_Follow:
{ {
package.reset(new AiFollow(&static_cast<const ESM::AiSequence::AiFollow&>(*container.mPackage))); package = std::make_unique<AiFollow>(&static_cast<const ESM::AiSequence::AiFollow&>(*container.mPackage));
break; break;
} }
case ESM::AiSequence::Ai_Activate: case ESM::AiSequence::Ai_Activate:
{ {
package.reset(new AiActivate(&static_cast<const ESM::AiSequence::AiActivate&>(*container.mPackage))); package = std::make_unique<AiActivate>(&static_cast<const ESM::AiSequence::AiActivate&>(*container.mPackage));
break; break;
} }
case ESM::AiSequence::Ai_Combat: case ESM::AiSequence::Ai_Combat:
{ {
package.reset(new AiCombat(&static_cast<const ESM::AiSequence::AiCombat&>(*container.mPackage))); package = std::make_unique<AiCombat>(&static_cast<const ESM::AiSequence::AiCombat&>(*container.mPackage));
break; break;
} }
case ESM::AiSequence::Ai_Pursue: case ESM::AiSequence::Ai_Pursue:
{ {
package.reset(new AiPursue(&static_cast<const ESM::AiSequence::AiPursue&>(*container.mPackage))); package = std::make_unique<AiPursue>(&static_cast<const ESM::AiSequence::AiPursue&>(*container.mPackage));
break; break;
} }
default: default:

View file

@ -123,7 +123,7 @@ namespace MWMechanics
void AiTravel::writeState(ESM::AiSequence::AiSequence &sequence) const void AiTravel::writeState(ESM::AiSequence::AiSequence &sequence) const
{ {
std::unique_ptr<ESM::AiSequence::AiTravel> travel(new ESM::AiSequence::AiTravel()); auto travel = std::make_unique<ESM::AiSequence::AiTravel>();
travel->mData.mX = mX; travel->mData.mX = mX;
travel->mData.mY = mY; travel->mData.mY = mY;
travel->mData.mZ = mZ; travel->mData.mZ = mZ;

View file

@ -899,7 +899,7 @@ namespace MWMechanics
else else
remainingDuration = mDuration; remainingDuration = mDuration;
std::unique_ptr<ESM::AiSequence::AiWander> wander(new ESM::AiSequence::AiWander()); auto wander = std::make_unique<ESM::AiSequence::AiWander>();
wander->mData.mDistance = mDistance; wander->mData.mDistance = mDistance;
wander->mData.mDuration = mDuration; wander->mData.mDuration = mDuration;
wander->mData.mTimeOfDay = mTimeOfDay; wander->mData.mTimeOfDay = mTimeOfDay;

View file

@ -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() << "\"."; 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<btBoxShape>(Misc::Convert::toBullet(mOriginalHalfExtents));
mRotationallyInvariant = (mMeshTranslation.x() == 0.0 && mMeshTranslation.y() == 0.0) && std::fabs(mOriginalHalfExtents.x() - mOriginalHalfExtents.y()) < 2.2; mRotationallyInvariant = (mMeshTranslation.x() == 0.0 && mMeshTranslation.y() == 0.0) && std::fabs(mOriginalHalfExtents.x() - mOriginalHalfExtents.y()) < 2.2;
mConvexShape = static_cast<btConvexShape*>(mShape.get()); mConvexShape = static_cast<btConvexShape*>(mShape.get());

View file

@ -98,7 +98,7 @@ namespace
namespace MWPhysics namespace MWPhysics
{ {
PhysicsSystem::PhysicsSystem(Resource::ResourceSystem* resourceSystem, osg::ref_ptr<osg::Group> parentNode) PhysicsSystem::PhysicsSystem(Resource::ResourceSystem* resourceSystem, osg::ref_ptr<osg::Group> parentNode)
: mShapeManager(new Resource::BulletShapeManager(resourceSystem->getVFS(), resourceSystem->getSceneManager(), resourceSystem->getNifFileManager())) : mShapeManager(std::make_unique<Resource::BulletShapeManager>(resourceSystem->getVFS(), resourceSystem->getSceneManager(), resourceSystem->getNifFileManager()))
, mResourceSystem(resourceSystem) , mResourceSystem(resourceSystem)
, mDebugDrawEnabled(false) , mDebugDrawEnabled(false)
, mTimeAccum(0.0f) , mTimeAccum(0.0f)
@ -891,8 +891,8 @@ namespace MWPhysics
return; return;
} }
mWaterCollisionObject.reset(new btCollisionObject()); mWaterCollisionObject = std::make_unique<btCollisionObject>();
mWaterCollisionShape.reset(new btStaticPlaneShape(btVector3(0,0,1), mWaterHeight)); mWaterCollisionShape = std::make_unique<btStaticPlaneShape>(btVector3(0,0,1), mWaterHeight);
mWaterCollisionObject->setCollisionShape(mWaterCollisionShape.get()); mWaterCollisionObject->setCollisionShape(mWaterCollisionShape.get());
mTaskScheduler->addCollisionObject(mWaterCollisionObject.get(), CollisionType_Water, mTaskScheduler->addCollisionObject(mWaterCollisionObject.get(), CollisionType_Water,
CollisionType_Actor|CollisionType_Projectile); CollisionType_Actor|CollisionType_Projectile);

View file

@ -147,7 +147,7 @@ void CreatureWeaponAnimation::updatePart(PartHolderPtr& scene, int slot)
{ {
osg::ref_ptr<osg::Node> attached = attach(itemModel, bonename, bonename, item.getType() == ESM::Light::sRecordId); osg::ref_ptr<osg::Node> attached = attach(itemModel, bonename, bonename, item.getType() == ESM::Light::sRecordId);
scene.reset(new PartHolder(attached)); scene = std::make_unique<PartHolder>(attached);
if (!item.getClass().getEnchantment(item).empty()) if (!item.getClass().getEnchantment(item).empty())
mGlowUpdater = SceneUtil::addEnchantedGlow(attached, mResourceSystem, item.getClass().getEnchantmentColor(item)); 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) if (slot == MWWorld::InventoryStore::Slot_CarriedRight)
source = mWeaponAnimationTime; source = mWeaponAnimationTime;
else else
source.reset(new NullAnimationTime); source = std::make_shared<NullAnimationTime>();
SceneUtil::AssignControllerSourcesVisitor assignVisitor(source); SceneUtil::AssignControllerSourcesVisitor assignVisitor(source);
attached->accept(assignVisitor); attached->accept(assignVisitor);

View file

@ -122,7 +122,7 @@ void LocalMap::saveFogOfWar(MWWorld::CellStore* cell)
if (segment.mFogOfWarImage && segment.mHasFogState) if (segment.mFogOfWarImage && segment.mHasFogState)
{ {
std::unique_ptr<ESM::FogState> fog (new ESM::FogState()); auto fog = std::make_unique<ESM::FogState>();
fog->mFogTextures.emplace_back(); fog->mFogTextures.emplace_back();
segment.saveFogOfWar(fog->mFogTextures.back()); segment.saveFogOfWar(fog->mFogTextures.back());
@ -134,7 +134,7 @@ void LocalMap::saveFogOfWar(MWWorld::CellStore* cell)
{ {
auto segments = divideIntoSegments(mBounds, mMapWorldSize); auto segments = divideIntoSegments(mBounds, mMapWorldSize);
std::unique_ptr<ESM::FogState> fog (new ESM::FogState()); auto fog = std::make_unique<ESM::FogState>();
fog->mBounds.mMinX = mBounds.xMin(); fog->mBounds.mMinX = mBounds.xMin();
fog->mBounds.mMaxX = mBounds.xMax(); fog->mBounds.mMaxX = mBounds.xMax();

View file

@ -401,7 +401,7 @@ namespace MWRender
if (Settings::Manager::getBool("terrain shadows", "Shadows")) if (Settings::Manager::getBool("terrain shadows", "Shadows"))
shadowCastingTraversalMask |= Mask_Terrain; 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<SceneUtil::ShadowManager>(sceneRoot, mRootNode, shadowCastingTraversalMask, indoorShadowCastingTraversalMask, Mask_Terrain|Mask_Object|Mask_Static, mResourceSystem->getSceneManager()->getShaderManager());
Shader::ShaderManager::DefineMap shadowDefines = mShadowManager->getShadowDefines(); Shader::ShaderManager::DefineMap shadowDefines = mShadowManager->getShadowDefines();
Shader::ShaderManager::DefineMap lightDefines = sceneRoot->getLightDefines(); 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. // It is unnecessary to stop/start the viewer as no frames are being rendered yet.
mResourceSystem->getSceneManager()->getShaderManager().setGlobalDefines(globalDefines); mResourceSystem->getSceneManager()->getShaderManager().setGlobalDefines(globalDefines);
mNavMesh.reset(new NavMesh(mRootNode, mWorkQueue, Settings::Manager::getBool("enable nav mesh render", "Navigator"), mNavMesh = std::make_unique<NavMesh>(mRootNode, mWorkQueue, Settings::Manager::getBool("enable nav mesh render", "Navigator"),
parseNavMeshMode(Settings::Manager::getString("nav mesh render mode", "Navigator")))); parseNavMeshMode(Settings::Manager::getString("nav mesh render mode", "Navigator")));
mActorsPaths.reset(new ActorsPaths(mRootNode, Settings::Manager::getBool("enable agents paths render", "Navigator"))); mActorsPaths = std::make_unique<ActorsPaths>(mRootNode, Settings::Manager::getBool("enable agents paths render", "Navigator"));
mRecastMesh.reset(new RecastMesh(mRootNode, Settings::Manager::getBool("enable recast mesh render", "Navigator"))); mRecastMesh = std::make_unique<RecastMesh>(mRootNode, Settings::Manager::getBool("enable recast mesh render", "Navigator"));
mPathgrid.reset(new Pathgrid(mRootNode)); mPathgrid = std::make_unique<Pathgrid>(mRootNode);
mObjects.reset(new Objects(mResourceSystem, sceneRoot)); mObjects = std::make_unique<Objects>(mResourceSystem, sceneRoot);
if (getenv("OPENMW_DONT_PRECOMPILE") == nullptr) if (getenv("OPENMW_DONT_PRECOMPILE") == nullptr)
{ {
@ -451,7 +451,7 @@ namespace MWRender
mResourceSystem->getSceneManager()->setIncrementalCompileOperation(mViewer->getIncrementalCompileOperation()); mResourceSystem->getSceneManager()->setIncrementalCompileOperation(mViewer->getIncrementalCompileOperation());
mEffectManager.reset(new EffectManager(sceneRoot, mResourceSystem)); mEffectManager = std::make_unique<EffectManager>(sceneRoot, mResourceSystem);
const std::string normalMapPattern = Settings::Manager::getString("normal map pattern", "Shaders"); const std::string normalMapPattern = Settings::Manager::getString("normal map pattern", "Shaders");
const std::string heightMapPattern = Settings::Manager::getString("normal height 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 useTerrainNormalMaps = Settings::Manager::getBool("auto use terrain normal maps", "Shaders");
const bool useTerrainSpecularMaps = Settings::Manager::getBool("auto use terrain specular 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<TerrainStorage>(mResourceSystem, normalMapPattern, heightMapPattern, useTerrainNormalMaps, specularMapPattern, useTerrainSpecularMaps);
const float lodFactor = Settings::Manager::getFloat("lod factor", "Terrain"); const float lodFactor = Settings::Manager::getFloat("lod factor", "Terrain");
bool groundcover = Settings::Manager::getBool("enabled", "Groundcover"); bool groundcover = Settings::Manager::getBool("enabled", "Groundcover");
@ -474,18 +474,18 @@ namespace MWRender
float maxCompGeometrySize = Settings::Manager::getFloat("max composite geometry size", "Terrain"); float maxCompGeometrySize = Settings::Manager::getFloat("max composite geometry size", "Terrain");
maxCompGeometrySize = std::max(maxCompGeometrySize, 1.f); maxCompGeometrySize = std::max(maxCompGeometrySize, 1.f);
bool debugChunks = Settings::Manager::getBool("debug chunks", "Terrain"); bool debugChunks = Settings::Manager::getBool("debug chunks", "Terrain");
mTerrain.reset(new Terrain::QuadTreeWorld( mTerrain = std::make_unique<Terrain::QuadTreeWorld>(
sceneRoot, mRootNode, mResourceSystem, mTerrainStorage.get(), Mask_Terrain, Mask_PreCompile, Mask_Debug, 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")) if (Settings::Manager::getBool("object paging", "Terrain"))
{ {
mObjectPaging.reset(new ObjectPaging(mResourceSystem->getSceneManager())); mObjectPaging = std::make_unique<ObjectPaging>(mResourceSystem->getSceneManager());
static_cast<Terrain::QuadTreeWorld*>(mTerrain.get())->addChunkManager(mObjectPaging.get()); static_cast<Terrain::QuadTreeWorld*>(mTerrain.get())->addChunkManager(mObjectPaging.get());
mResourceSystem->addResourceManager(mObjectPaging.get()); mResourceSystem->addResourceManager(mObjectPaging.get());
} }
} }
else else
mTerrain.reset(new Terrain::TerrainGrid(sceneRoot, mRootNode, mResourceSystem, mTerrainStorage.get(), Mask_Terrain, Mask_PreCompile, Mask_Debug)); mTerrain = std::make_unique<Terrain::TerrainGrid>(sceneRoot, mRootNode, mResourceSystem, mTerrainStorage.get(), Mask_Terrain, Mask_PreCompile, Mask_Debug);
mTerrain->setTargetFrameRate(Settings::Manager::getFloat("target framerate", "Cells")); mTerrain->setTargetFrameRate(Settings::Manager::getFloat("target framerate", "Cells"));
@ -494,7 +494,7 @@ namespace MWRender
float density = Settings::Manager::getFloat("density", "Groundcover"); float density = Settings::Manager::getFloat("density", "Groundcover");
density = std::clamp(density, 0.f, 1.f); density = std::clamp(density, 0.f, 1.f);
mGroundcover.reset(new Groundcover(mResourceSystem->getSceneManager(), density, groundcoverDistance, groundcoverStore)); mGroundcover = std::make_unique<Groundcover>(mResourceSystem->getSceneManager(), density, groundcoverDistance, groundcoverStore);
static_cast<Terrain::QuadTreeWorld*>(mTerrain.get())->addChunkManager(mGroundcover.get()); static_cast<Terrain::QuadTreeWorld*>(mTerrain.get())->addChunkManager(mGroundcover.get());
mResourceSystem->addResourceManager(mGroundcover.get()); mResourceSystem->addResourceManager(mGroundcover.get());
} }
@ -513,11 +513,11 @@ namespace MWRender
resourceSystem->getSceneManager()->setSupportsNormalsRT(mPostProcessor->getSupportsNormalsRT()); resourceSystem->getSceneManager()->setSupportsNormalsRT(mPostProcessor->getSupportsNormalsRT());
// water goes after terrain for correct waterculling order // water goes after terrain for correct waterculling order
mWater.reset(new Water(sceneRoot->getParent(0), sceneRoot, mResourceSystem, mViewer->getIncrementalCompileOperation(), resourcePath)); mWater = std::make_unique<Water>(sceneRoot->getParent(0), sceneRoot, mResourceSystem, mViewer->getIncrementalCompileOperation(), resourcePath);
mCamera.reset(new Camera(mViewer->getCamera())); mCamera = std::make_unique<Camera>(mViewer->getCamera());
mScreenshotManager.reset(new ScreenshotManager(viewer, mRootNode, sceneRoot, mResourceSystem, mWater.get())); mScreenshotManager = std::make_unique<ScreenshotManager>(viewer, mRootNode, sceneRoot, mResourceSystem, mWater.get());
mViewer->setLightingMode(osgViewer::View::NO_LIGHT); 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("emissiveMult", 1.f));
sceneRoot->getOrCreateStateSet()->addUniform(new osg::Uniform("specStrength", 1.f)); sceneRoot->getOrCreateStateSet()->addUniform(new osg::Uniform("specStrength", 1.f));
mFog.reset(new FogManager()); mFog = std::make_unique<FogManager>();
mSky.reset(new SkyManager(sceneRoot, resourceSystem->getSceneManager())); mSky = std::make_unique<SkyManager>(sceneRoot, resourceSystem->getSceneManager());
mSky->setCamera(mViewer->getCamera()); mSky->setCamera(mViewer->getCamera());
source->setStateSetModes(*mRootNode->getOrCreateStateSet(), osg::StateAttribute::ON); source->setStateSetModes(*mRootNode->getOrCreateStateSet(), osg::StateAttribute::ON);

View file

@ -303,10 +303,10 @@ namespace MWRender
mAtmosphereNightUpdater = new AtmosphereNightUpdater(mSceneManager->getImageManager(), forceShaders); mAtmosphereNightUpdater = new AtmosphereNightUpdater(mSceneManager->getImageManager(), forceShaders);
atmosphereNight->addUpdateCallback(mAtmosphereNightUpdater); atmosphereNight->addUpdateCallback(mAtmosphereNightUpdater);
mSun.reset(new Sun(mEarlyRenderBinRoot, *mSceneManager)); mSun = std::make_unique<Sun>(mEarlyRenderBinRoot, *mSceneManager);
mSun->setSunglare(mSunglareEnabled); mSun->setSunglare(mSunglareEnabled);
mMasser.reset(new Moon(mEarlyRenderBinRoot, *mSceneManager, Fallback::Map::getFloat("Moons_Masser_Size")/125, Moon::Type_Masser)); mMasser = std::make_unique<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)); mSecunda = std::make_unique<Moon>(mEarlyRenderBinRoot, *mSceneManager, Fallback::Map::getFloat("Moons_Secunda_Size")/125, Moon::Type_Secunda);
mCloudNode = new osg::Group; mCloudNode = new osg::Group;
mEarlyRenderBinRoot->addChild(mCloudNode); mEarlyRenderBinRoot->addChild(mCloudNode);

View file

@ -456,7 +456,7 @@ Water::Water(osg::Group *parent, osg::Group* sceneRoot, Resource::ResourceSystem
, mCullCallback(nullptr) , mCullCallback(nullptr)
, mShaderWaterStateSetUpdater(nullptr) , mShaderWaterStateSetUpdater(nullptr)
{ {
mSimulation.reset(new RippleSimulation(mSceneRoot, resourceSystem)); mSimulation = std::make_unique<RippleSimulation>(mSceneRoot, resourceSystem);
mWaterGeom = SceneUtil::createWaterGeometry(Constants::CellSizeInUnits*150, 40, 900); mWaterGeom = SceneUtil::createWaterGeometry(Constants::CellSizeInUnits*150, 40, 900);
mWaterGeom->setDrawCallback(new DepthClampCallback); mWaterGeom->setDrawCallback(new DepthClampCallback);

View file

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

View file

@ -428,7 +428,7 @@ bool OpenAL_SoundStream::init(bool getLoudnessData)
mBufferSize *= mFrameSize; mBufferSize *= mFrameSize;
if (getLoudnessData) if (getLoudnessData)
mLoudnessAnalyzer.reset(new Sound_Loudness(sLoudnessFPS, mSampleRate, chans, type)); mLoudnessAnalyzer = std::make_unique<Sound_Loudness>(sLoudnessFPS, mSampleRate, chans, type);
mIsFinished = false; mIsFinished = false;
return true; return true;
@ -1501,7 +1501,7 @@ OpenAL_Output::OpenAL_Output(SoundManager &mgr)
, mDevice(nullptr), mContext(nullptr) , mDevice(nullptr), mContext(nullptr)
, mListenerPos(0.0f, 0.0f, 0.0f), mListenerEnv(Env_Normal) , mListenerPos(0.0f, 0.0f, 0.0f), mListenerEnv(Env_Normal)
, mWaterFilter(0), mWaterEffect(0), mDefaultEffect(0), mEffectSlot(0) , mWaterFilter(0), mWaterEffect(0), mDefaultEffect(0), mEffectSlot(0)
, mStreamThread(new StreamThread) , mStreamThread(std::make_unique<StreamThread>())
{ {
} }

View file

@ -792,7 +792,7 @@ namespace MWWorld
void CellStore::readFog(ESM::ESMReader &reader) void CellStore::readFog(ESM::ESMReader &reader)
{ {
mFogState.reset(new ESM::FogState()); mFogState = std::make_unique<ESM::FogState>();
mFogState->load(reader); mFogState->load(reader);
} }

View file

@ -117,12 +117,12 @@ namespace MWWorld
std::unique_ptr<Action> Class::activate (const Ptr& ptr, const Ptr& actor) const std::unique_ptr<Action> Class::activate (const Ptr& ptr, const Ptr& actor) const
{ {
return std::unique_ptr<Action> (new NullAction); return std::make_unique<NullAction>();
} }
std::unique_ptr<Action> Class::use (const Ptr& ptr, bool force) const std::unique_ptr<Action> Class::use (const Ptr& ptr, bool force) const
{ {
return std::unique_ptr<Action> (new NullAction); return std::make_unique<NullAction>();
} }
ContainerStore& Class::getContainerStore (const Ptr& ptr) const ContainerStore& Class::getContainerStore (const Ptr& ptr) const
@ -332,7 +332,7 @@ namespace MWWorld
std::unique_ptr<Action> Class::defaultItemActivate(const Ptr &ptr, const Ptr &actor) const std::unique_ptr<Action> Class::defaultItemActivate(const Ptr &ptr, const Ptr &actor) const
{ {
if(!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory)) if(!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
return std::unique_ptr<Action>(new NullAction()); return std::make_unique<NullAction>();
if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf())
{ {
@ -340,13 +340,13 @@ namespace MWWorld
auto& prng = MWBase::Environment::get().getWorld()->getPrng(); auto& prng = MWBase::Environment::get().getWorld()->getPrng();
const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfItem", prng); const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfItem", prng);
std::unique_ptr<MWWorld::Action> action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); std::unique_ptr<MWWorld::Action> action = std::make_unique<MWWorld::FailedAction>("#{sWerewolfRefusal}");
if(sound) action->setSound(sound->mId); if(sound) action->setSound(sound->mId);
return action; return action;
} }
std::unique_ptr<MWWorld::Action> action(new ActionTake(ptr)); std::unique_ptr<MWWorld::Action> action = std::make_unique<ActionTake>(ptr);
action->setSound(getUpSoundId(ptr)); action->setSound(getUpSoundId(ptr));
return action; return action;

View file

@ -772,7 +772,7 @@ namespace MWWorld
, mPreloadFastTravel(Settings::Manager::getBool("preload fast travel", "Cells")) , mPreloadFastTravel(Settings::Manager::getBool("preload fast travel", "Cells"))
, mPredictionTime(Settings::Manager::getFloat("prediction time", "Cells")) , mPredictionTime(Settings::Manager::getFloat("prediction time", "Cells"))
{ {
mPreloader.reset(new CellPreloader(rendering.getResourceSystem(), physics->getShapeManager(), rendering.getTerrain(), rendering.getLandManager())); mPreloader = std::make_unique<CellPreloader>(rendering.getResourceSystem(), physics->getShapeManager(), rendering.getTerrain(), rendering.getLandManager());
mPreloader->setWorkQueue(mRendering.getWorkQueue()); mPreloader->setWorkQueue(mRendering.getWorkQueue());
rendering.getResourceSystem()->setExpiryDelay(Settings::Manager::getFloat("cache expiry delay", "Cells")); rendering.getResourceSystem()->setExpiryDelay(Settings::Manager::getFloat("cache expiry delay", "Cells"));

View file

@ -175,7 +175,7 @@ namespace MWWorld
break; break;
} }
mCurrentDate.reset(new DateTimeManager()); mCurrentDate = std::make_unique<DateTimeManager>();
fillGlobalVariables(); fillGlobalVariables();
@ -184,7 +184,7 @@ namespace MWWorld
mSwimHeightScale = mStore.get<ESM::GameSetting>().find("fSwimHeightScale")->mValue.getFloat(); mSwimHeightScale = mStore.get<ESM::GameSetting>().find("fSwimHeightScale")->mValue.getFloat();
mPhysics.reset(new MWPhysics::PhysicsSystem(resourceSystem, rootNode)); mPhysics = std::make_unique<MWPhysics::PhysicsSystem>(resourceSystem, rootNode);
if (Settings::Manager::getBool("enable", "Navigator")) if (Settings::Manager::getBool("enable", "Navigator"))
{ {
@ -197,13 +197,13 @@ namespace MWWorld
mNavigator = DetourNavigator::makeNavigatorStub(); mNavigator = DetourNavigator::makeNavigatorStub();
} }
mRendering.reset(new MWRender::RenderingManager(viewer, rootNode, resourceSystem, workQueue, resourcePath, *mNavigator, mGroundcoverStore)); mRendering = std::make_unique<MWRender::RenderingManager>(viewer, rootNode, resourceSystem, workQueue, resourcePath, *mNavigator, mGroundcoverStore);
mProjectileManager.reset(new ProjectileManager(mRendering->getLightRoot()->asGroup(), resourceSystem, mRendering.get(), mPhysics.get())); mProjectileManager = std::make_unique<ProjectileManager>(mRendering->getLightRoot()->asGroup(), resourceSystem, mRendering.get(), mPhysics.get());
mRendering->preloadCommonAssets(); mRendering->preloadCommonAssets();
mWeatherManager.reset(new MWWorld::WeatherManager(*mRendering, mStore)); mWeatherManager = std::make_unique<MWWorld::WeatherManager>(*mRendering, mStore);
mWorldScene.reset(new Scene(*this, *mRendering.get(), mPhysics.get(), *mNavigator)); mWorldScene = std::make_unique<Scene>(*this, *mRendering.get(), mPhysics.get(), *mNavigator);
} }
void World::fillGlobalVariables() void World::fillGlobalVariables()
@ -231,7 +231,7 @@ namespace MWWorld
// we don't want old weather to persist on a new game // 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. // Note that if reset later, the initial ChangeWeather that the chargen script calls will be lost.
mWeatherManager.reset(); mWeatherManager.reset();
mWeatherManager.reset(new MWWorld::WeatherManager(*mRendering.get(), mStore)); mWeatherManager = std::make_unique<MWWorld::WeatherManager>(*mRendering.get(), mStore);
if (!bypass) if (!bypass)
{ {
@ -2443,7 +2443,7 @@ namespace MWWorld
{ {
const ESM::NPC *player = mStore.get<ESM::NPC>().find("player"); const ESM::NPC *player = mStore.get<ESM::NPC>().find("player");
if (!mPlayer) if (!mPlayer)
mPlayer.reset(new MWWorld::Player(player)); mPlayer = std::make_unique<MWWorld::Player>(player);
else else
{ {
// Remove the old CharacterController // Remove the old CharacterController

View file

@ -21,8 +21,7 @@ void DataManager::setResourcePath(const std::string &path)
MyGUI::IDataStream *DataManager::getData(const std::string &name) const MyGUI::IDataStream *DataManager::getData(const std::string &name) const
{ {
std::string fullpath = getDataPath(name); std::string fullpath = getDataPath(name);
std::unique_ptr<std::ifstream> stream; auto stream = std::make_unique<std::ifstream>();
stream.reset(new std::ifstream);
stream->open(fullpath, std::ios::binary); stream->open(fullpath, std::ios::binary);
if (stream->fail()) if (stream->fail())
{ {

View file

@ -140,7 +140,7 @@ std::monostate fillTriangleMesh(std::unique_ptr<btTriangleMesh>& mesh, const Nif
return handleNiGeometry(geometry, [&] (const auto& data) return handleNiGeometry(geometry, [&] (const auto& data)
{ {
if (mesh == nullptr) if (mesh == nullptr)
mesh.reset(new btTriangleMesh(false)); mesh = std::make_unique<btTriangleMesh>(false);
fillTriangleMesh(*mesh, data, transform); fillTriangleMesh(*mesh, data, transform);
return std::monostate {}; return std::monostate {};
}); });
@ -150,7 +150,7 @@ std::unique_ptr<btTriangleMesh> makeChildMesh(const Nif::NiGeometry& geometry)
{ {
return handleNiGeometry(geometry, [&] (const auto& data) return handleNiGeometry(geometry, [&] (const auto& data)
{ {
std::unique_ptr<btTriangleMesh> mesh(new btTriangleMesh); auto mesh = std::make_unique<btTriangleMesh>();
fillTriangleMesh(*mesh, data, osg::Matrixf()); fillTriangleMesh(*mesh, data, osg::Matrixf());
return mesh; return mesh;
}); });
@ -197,8 +197,8 @@ osg::ref_ptr<Resource::BulletShape> BulletNifLoader::load(const Nif::File& nif)
{ {
const btVector3 extents = Misc::Convert::toBullet(mShape->mCollisionBox.mExtents); const btVector3 extents = Misc::Convert::toBullet(mShape->mCollisionBox.mExtents);
const btVector3 center = Misc::Convert::toBullet(mShape->mCollisionBox.mCenter); const btVector3 center = Misc::Convert::toBullet(mShape->mCollisionBox.mCenter);
std::unique_ptr<btCompoundShape> compound (new btCompoundShape); auto compound = std::make_unique<btCompoundShape>();
std::unique_ptr<btBoxShape> boxShape(new btBoxShape(extents)); auto boxShape = std::make_unique<btBoxShape>(extents);
btTransform transform = btTransform::getIdentity(); btTransform transform = btTransform::getIdentity();
transform.setOrigin(center); transform.setOrigin(center);
compound->addChildShape(transform, boxShape.get()); compound->addChildShape(transform, boxShape.get());
@ -226,7 +226,7 @@ osg::ref_ptr<Resource::BulletShape> BulletNifLoader::load(const Nif::File& nif)
{ {
btTransform trans; btTransform trans;
trans.setIdentity(); trans.setIdentity();
std::unique_ptr<btCollisionShape> child(new Resource::TriangleMeshShape(mStaticMesh.get(), true)); std::unique_ptr<btCollisionShape> child = std::make_unique<Resource::TriangleMeshShape>(mStaticMesh.get(), true);
mCompoundShape->addChildShape(trans, child.get()); mCompoundShape->addChildShape(trans, child.get());
child.release(); child.release();
mStaticMesh.release(); mStaticMesh.release();
@ -407,7 +407,7 @@ void BulletNifLoader::handleNiTriShape(const Nif::NiGeometry& niGeometry, const
if (!mCompoundShape) if (!mCompoundShape)
mCompoundShape.reset(new btCompoundShape); mCompoundShape.reset(new btCompoundShape);
std::unique_ptr<Resource::TriangleMeshShape> childShape(new Resource::TriangleMeshShape(childMesh.get(), true)); auto childShape = std::make_unique<Resource::TriangleMeshShape>(childMesh.get(), true);
childMesh.release(); childMesh.release();
float scale = niGeometry.trafo.scale; float scale = niGeometry.trafo.scale;

View file

@ -13,10 +13,10 @@ namespace Resource
ResourceSystem::ResourceSystem(const VFS::Manager *vfs) ResourceSystem::ResourceSystem(const VFS::Manager *vfs)
: mVFS(vfs) : mVFS(vfs)
{ {
mNifFileManager.reset(new NifFileManager(vfs)); mNifFileManager = std::make_unique<NifFileManager>(vfs);
mImageManager.reset(new ImageManager(vfs)); mImageManager = std::make_unique<ImageManager>(vfs);
mSceneManager.reset(new SceneManager(vfs, mImageManager.get(), mNifFileManager.get())); mSceneManager = std::make_unique<SceneManager>(vfs, mImageManager.get(), mNifFileManager.get());
mKeyframeManager.reset(new KeyframeManager(vfs, mSceneManager.get())); mKeyframeManager = std::make_unique<KeyframeManager>(vfs, mSceneManager.get());
addResourceManager(mNifFileManager.get()); addResourceManager(mNifFileManager.get());
addResourceManager(mKeyframeManager.get()); addResourceManager(mKeyframeManager.get());

View file

@ -69,7 +69,7 @@ Bone* Skeleton::getBone(const std::string &name)
if (!mRootBone.get()) if (!mRootBone.get())
{ {
mRootBone.reset(new Bone); mRootBone = std::make_unique<Bone>();
} }
Bone* bone = mRootBone.get(); Bone* bone = mRootBone.get();

View file

@ -287,7 +287,7 @@ QuadTreeWorld::QuadTreeWorld(osg::Group *parent, osg::Group *compileRoot, Resour
if (mDebugTerrainChunks) if (mDebugTerrainChunks)
{ {
mDebugChunkManager = std::unique_ptr<DebugChunkManager>(new DebugChunkManager(mResourceSystem->getSceneManager(), mStorage, borderMask)); mDebugChunkManager = std::make_unique<DebugChunkManager>(mResourceSystem->getSceneManager(), mStorage, borderMask);
addChunkManager(mDebugChunkManager.get()); addChunkManager(mDebugChunkManager.get());
} }
} }

View file

@ -41,10 +41,10 @@ World::World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSyst
mParent->addChild(mTerrainRoot); mParent->addChild(mTerrainRoot);
mTextureManager.reset(new TextureManager(mResourceSystem->getSceneManager())); mTextureManager = std::make_unique<TextureManager>(mResourceSystem->getSceneManager());
mChunkManager.reset(new ChunkManager(mStorage, mResourceSystem->getSceneManager(), mTextureManager.get(), mCompositeMapRenderer)); mChunkManager = std::make_unique<ChunkManager>(mStorage, mResourceSystem->getSceneManager(), mTextureManager.get(), mCompositeMapRenderer);
mChunkManager->setNodeMask(nodeMask); mChunkManager->setNodeMask(nodeMask);
mCellBorder.reset(new CellBorder(this,mTerrainRoot.get(),borderMask,mResourceSystem->getSceneManager())); mCellBorder = std::make_unique<CellBorder>(this,mTerrainRoot.get(),borderMask,mResourceSystem->getSceneManager());
mResourceSystem->addResourceManager(mChunkManager.get()); mResourceSystem->addResourceManager(mChunkManager.get());
mResourceSystem->addResourceManager(mTextureManager.get()); mResourceSystem->addResourceManager(mTextureManager.get());