CDependencyTree: Make use of unique_ptr

Makes the ownership semantics explicit in the interface.
This commit is contained in:
Lioncash
2020-06-12 13:46:49 -04:00
parent e2190793fd
commit 7da16efe9d
4 changed files with 48 additions and 51 deletions

View File

@@ -2,6 +2,8 @@
#define CANIMEVENTDATA
#include "Core/Resource/CResource.h"
#include <memory>
#include <vector>
class CAnimEventData : public CResource
{
@@ -36,8 +38,7 @@ public:
if (ID.IsValid() && !pTree->HasDependency(ID))
{
auto *pDep = new CAnimEventDependency(ID, event.mCharacterIndex);
pTree->AddChild(pDep);
pTree->AddChild(std::make_unique<CAnimEventDependency>(ID, event.mCharacterIndex));
}
}
}

View File

@@ -124,9 +124,9 @@ public:
// Character dependencies
for (const auto& character : mCharacters)
{
CSetCharacterDependency *pCharTree = CSetCharacterDependency::BuildTree(character);
auto pCharTree = CSetCharacterDependency::BuildTree(character);
ASSERT(pCharTree);
pTree->AddChild(pCharTree);
pTree->AddChild(std::move(pCharTree));
}
// Animation dependencies
@@ -134,9 +134,9 @@ public:
{
for (uint32 iAnim = 0; iAnim < mAnimations.size(); iAnim++)
{
CSetAnimationDependency *pAnimTree = CSetAnimationDependency::BuildTree(this, iAnim);
auto pAnimTree = CSetAnimationDependency::BuildTree(this, iAnim);
ASSERT(pAnimTree);
pTree->AddChild(pAnimTree);
pTree->AddChild(std::move(pAnimTree));
}
}
else if (Game() <= EGame::Corruption)