From 4eb10273623e55ac06f00dab91aa9db0b332a498 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 12 Jun 2020 10:03:02 -0400 Subject: [PATCH] CAnimSet: Collapse loops into ranged for where applicable --- src/Core/Resource/Animation/CAnimSet.h | 33 +++++++++++++------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/Core/Resource/Animation/CAnimSet.h b/src/Core/Resource/Animation/CAnimSet.h index 4c758b23..a1db3f3e 100644 --- a/src/Core/Resource/Animation/CAnimSet.h +++ b/src/Core/Resource/Animation/CAnimSet.h @@ -96,36 +96,35 @@ class CAnimSet : public CResource std::vector mAnimPrimitives; std::vector mAnimations; std::vector mTransitions; - IMetaTransition *mpDefaultTransition; + IMetaTransition *mpDefaultTransition = nullptr; std::vector mAdditiveAnims; - float mDefaultAdditiveFadeIn; - float mDefaultAdditiveFadeOut; + float mDefaultAdditiveFadeIn = 0.0f; + float mDefaultAdditiveFadeOut = 0.0f; std::vector mHalfTransitions; std::vector> mAnimEvents; // note: these are for MP2, where event data isn't a standalone resource; these are owned by the animset public: - CAnimSet(CResourceEntry *pEntry = 0) + explicit CAnimSet(CResourceEntry *pEntry = nullptr) : CResource(pEntry) - , mpDefaultTransition(nullptr) {} ~CAnimSet() { - for (uint32 iAnim = 0; iAnim < mAnimations.size(); iAnim++) - delete mAnimations[iAnim].pMetaAnim; + for (auto& anim : mAnimations) + delete anim.pMetaAnim; - for (uint32 iTrans = 0; iTrans < mTransitions.size(); iTrans++) - delete mTransitions[iTrans].pMetaTrans; + for (auto& trans : mTransitions) + delete trans.pMetaTrans; - for (uint32 iHalf = 0; iHalf < mHalfTransitions.size(); iHalf++) - delete mHalfTransitions[iHalf].pMetaTrans; + for (auto& half : mHalfTransitions) + delete half.pMetaTrans; delete mpDefaultTransition; // For MP2, anim events need to be cleaned up manually - for (uint32 iEvent = 0; iEvent < mAnimEvents.size(); iEvent++) + for ([[maybe_unused]] const auto& event : mAnimEvents) { - ASSERT(mAnimEvents[iEvent] && !mAnimEvents[iEvent]->Entry()); + ASSERT(event != nullptr && !event->Entry()); } } @@ -206,16 +205,16 @@ public: } // Accessors - inline uint32 NumCharacters() const { return mCharacters.size(); } - inline uint32 NumAnimations() const { return mAnimations.size(); } + uint32 NumCharacters() const { return mCharacters.size(); } + uint32 NumAnimations() const { return mAnimations.size(); } - inline const SSetCharacter* Character(uint32 Index) const + const SSetCharacter* Character(uint32 Index) const { ASSERT(Index >= 0 && Index < NumCharacters()); return &mCharacters[Index]; } - inline const SAnimation* Animation(uint32 Index) const + const SAnimation* Animation(uint32 Index) const { ASSERT(Index >= 0 && Index < NumAnimations()); return &mAnimations[Index];