From d4ce5a2ac6273eaebec8b1ba130e7afbfd2a686e Mon Sep 17 00:00:00 2001 From: elsid Date: Fri, 29 Aug 2025 19:28:57 +0200 Subject: [PATCH] Fix and enforce enum naming --- .clang-tidy | 2 + .../view/render/pagedworldspacewidget.cpp | 4 +- .../view/render/pagedworldspacewidget.hpp | 2 +- .../view/render/unpagedworldspacewidget.cpp | 4 +- .../view/render/unpagedworldspacewidget.hpp | 2 +- apps/opencs/view/render/worldspacewidget.cpp | 2 +- apps/opencs/view/render/worldspacewidget.hpp | 4 +- apps/opencs/view/world/scenesubview.cpp | 4 +- apps/opencs/view/world/scenesubview.hpp | 4 +- components/compiler/scanner.hpp | 4 +- components/esm4/loadcrea.hpp | 4 +- components/esm4/loadnpc.hpp | 8 +-- components/esm4/loadqust.hpp | 2 +- components/nif/physics.cpp | 54 +++++++++---------- components/nif/physics.hpp | 30 +++++------ 15 files changed, 66 insertions(+), 64 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 91a1af88c7..17d99a3ad5 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -15,6 +15,8 @@ ExcludeHeaderFilterRegex: '_autogen/' CheckOptions: - key: readability-identifier-naming.ConceptCase value: CamelCase +- key: readability-identifier-naming.EnumCase + value: CamelCase - key: readability-identifier-naming.LocalVariableCase value: camelBack - key: readability-identifier-naming.NamespaceCase diff --git a/apps/opencs/view/render/pagedworldspacewidget.cpp b/apps/opencs/view/render/pagedworldspacewidget.cpp index 90670a4d62..c48e8b8d91 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.cpp +++ b/apps/opencs/view/render/pagedworldspacewidget.cpp @@ -719,10 +719,10 @@ bool CSVRender::PagedWorldspaceWidget::handleDrop( return true; } -CSVRender::WorldspaceWidget::dropRequirments CSVRender::PagedWorldspaceWidget::getDropRequirements( +CSVRender::WorldspaceWidget::DropRequirements CSVRender::PagedWorldspaceWidget::getDropRequirements( CSVRender::WorldspaceWidget::DropType type) const { - dropRequirments requirements = WorldspaceWidget::getDropRequirements(type); + DropRequirements requirements = WorldspaceWidget::getDropRequirements(type); if (requirements != ignored) return requirements; diff --git a/apps/opencs/view/render/pagedworldspacewidget.hpp b/apps/opencs/view/render/pagedworldspacewidget.hpp index dc47d5ea04..ef76277c10 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.hpp +++ b/apps/opencs/view/render/pagedworldspacewidget.hpp @@ -120,7 +120,7 @@ namespace CSVRender /// \return Drop handled? bool handleDrop(const std::vector& data, DropType type) override; - dropRequirments getDropRequirements(DropType type) const override; + DropRequirements getDropRequirements(DropType type) const override; /// \attention The created tool is not added to the toolbar (via addTool). Doing /// that is the responsibility of the calling function. diff --git a/apps/opencs/view/render/unpagedworldspacewidget.cpp b/apps/opencs/view/render/unpagedworldspacewidget.cpp index 3637663356..ff0c5af8ea 100644 --- a/apps/opencs/view/render/unpagedworldspacewidget.cpp +++ b/apps/opencs/view/render/unpagedworldspacewidget.cpp @@ -365,10 +365,10 @@ std::string CSVRender::UnpagedWorldspaceWidget::getStartupInstruction() return stream.str(); } -CSVRender::WorldspaceWidget::dropRequirments CSVRender::UnpagedWorldspaceWidget::getDropRequirements( +CSVRender::WorldspaceWidget::DropRequirements CSVRender::UnpagedWorldspaceWidget::getDropRequirements( CSVRender::WorldspaceWidget::DropType type) const { - dropRequirments requirements = WorldspaceWidget::getDropRequirements(type); + DropRequirements requirements = WorldspaceWidget::getDropRequirements(type); if (requirements != ignored) return requirements; diff --git a/apps/opencs/view/render/unpagedworldspacewidget.hpp b/apps/opencs/view/render/unpagedworldspacewidget.hpp index 6eb5b97f56..6d4e29fbdf 100644 --- a/apps/opencs/view/render/unpagedworldspacewidget.hpp +++ b/apps/opencs/view/render/unpagedworldspacewidget.hpp @@ -59,7 +59,7 @@ namespace CSVRender public: UnpagedWorldspaceWidget(const std::string& cellId, CSMDoc::Document& document, QWidget* parent); - dropRequirments getDropRequirements(DropType type) const override; + DropRequirements getDropRequirements(DropType type) const override; /// \return Drop handled? bool handleDrop(const std::vector& data, DropType type) override; diff --git a/apps/opencs/view/render/worldspacewidget.cpp b/apps/opencs/view/render/worldspacewidget.cpp index d5beacabe8..bdafc57498 100644 --- a/apps/opencs/view/render/worldspacewidget.cpp +++ b/apps/opencs/view/render/worldspacewidget.cpp @@ -323,7 +323,7 @@ CSVRender::WorldspaceWidget::DropType CSVRender::WorldspaceWidget::getDropType( return output; } -CSVRender::WorldspaceWidget::dropRequirments CSVRender::WorldspaceWidget::getDropRequirements(DropType type) const +CSVRender::WorldspaceWidget::DropRequirements CSVRender::WorldspaceWidget::getDropRequirements(DropType type) const { if (type == Type_DebugProfile) return canHandle; diff --git a/apps/opencs/view/render/worldspacewidget.hpp b/apps/opencs/view/render/worldspacewidget.hpp index 831ed13640..1e7112721f 100644 --- a/apps/opencs/view/render/worldspacewidget.hpp +++ b/apps/opencs/view/render/worldspacewidget.hpp @@ -101,7 +101,7 @@ namespace CSVRender Type_DebugProfile }; - enum dropRequirments + enum DropRequirements { canHandle, needPaged, @@ -145,7 +145,7 @@ namespace CSVRender static DropType getDropType(const std::vector& data); - virtual dropRequirments getDropRequirements(DropType type) const; + virtual DropRequirements getDropRequirements(DropType type) const; virtual void useViewHint(const std::string& hint); ///< Default-implementation: ignored. diff --git a/apps/opencs/view/world/scenesubview.cpp b/apps/opencs/view/world/scenesubview.cpp index 3b3ada43b5..a23c13684a 100644 --- a/apps/opencs/view/world/scenesubview.cpp +++ b/apps/opencs/view/world/scenesubview.cpp @@ -45,7 +45,7 @@ CSVWorld::SceneSubView::SceneSubView(const CSMWorld::UniversalId& id, CSMDoc::Do mLayout->setContentsMargins(QMargins(0, 0, 0, 0)); CSVRender::WorldspaceWidget* worldspaceWidget = nullptr; - widgetType whatWidget; + WidgetType whatWidget; if (Misc::StringUtils::ciEqual(id.getId(), ESM::Cell::sDefaultWorldspaceId.getValue())) { @@ -108,7 +108,7 @@ void CSVWorld::SceneSubView::makeConnections(CSVRender::PagedWorldspaceWidget* w connect(widget, &CSVRender::PagedWorldspaceWidget::requestFocus, this, &SceneSubView::requestFocus); } -CSVWidget::SceneToolbar* CSVWorld::SceneSubView::makeToolbar(CSVRender::WorldspaceWidget* widget, widgetType type) +CSVWidget::SceneToolbar* CSVWorld::SceneSubView::makeToolbar(CSVRender::WorldspaceWidget* widget, WidgetType type) { CSVWidget::SceneToolbar* toolbar = new CSVWidget::SceneToolbar(48 + 6, this); diff --git a/apps/opencs/view/world/scenesubview.hpp b/apps/opencs/view/world/scenesubview.hpp index 7248efd145..f889c5473d 100644 --- a/apps/opencs/view/world/scenesubview.hpp +++ b/apps/opencs/view/world/scenesubview.hpp @@ -65,13 +65,13 @@ namespace CSVWorld void replaceToolbarAndWorldspace(CSVRender::WorldspaceWidget* widget, CSVWidget::SceneToolbar* toolbar); - enum widgetType + enum WidgetType { widget_Paged, widget_Unpaged }; - CSVWidget::SceneToolbar* makeToolbar(CSVRender::WorldspaceWidget* widget, widgetType type); + CSVWidget::SceneToolbar* makeToolbar(CSVRender::WorldspaceWidget* widget, WidgetType type); private slots: diff --git a/components/compiler/scanner.hpp b/components/compiler/scanner.hpp index 5132bfe452..53bed2c098 100644 --- a/components/compiler/scanner.hpp +++ b/components/compiler/scanner.hpp @@ -181,7 +181,7 @@ namespace Compiler class Scanner { - enum putback_type + enum PutbackType { Putback_None, Putback_Special, @@ -196,7 +196,7 @@ namespace Compiler TokenLoc mPrevLoc; std::istream& mStream; const Extensions* mExtensions; - putback_type mPutback; + PutbackType mPutback; int mPutbackCode; int mPutbackInteger; float mPutbackFloat; diff --git a/components/esm4/loadcrea.hpp b/components/esm4/loadcrea.hpp index 30068daf89..11ab8bbc98 100644 --- a/components/esm4/loadcrea.hpp +++ b/components/esm4/loadcrea.hpp @@ -44,7 +44,7 @@ namespace ESM4 struct Creature { - enum ACBS_TES4 + enum ActorBaseFlagsTes4 { TES4_Essential = 0x000002, TES4_WeapAndShield = 0x000004, @@ -59,7 +59,7 @@ namespace ESM4 TES4_NoCorpseCheck = 0x100000 // opposite of npc_ }; - enum ACBS_FO3 + enum ActorBaseFlagsFo3 { FO3_Biped = 0x00000001, FO3_Essential = 0x00000002, diff --git a/components/esm4/loadnpc.hpp b/components/esm4/loadnpc.hpp index 04e56b7bd9..cb1d3bc07a 100644 --- a/components/esm4/loadnpc.hpp +++ b/components/esm4/loadnpc.hpp @@ -44,7 +44,7 @@ namespace ESM4 struct Npc { - enum ACBS_TES4 + enum ActorBaseFlagsTes4 { TES4_Female = 0x000001, TES4_Essential = 0x000002, @@ -58,7 +58,7 @@ namespace ESM4 TES4_CanCorpseCheck = 0x100000 // opposite of crea }; - enum ACBS_FO3 + enum ActorBaseFlagsFo3 { FO3_Female = 0x00000001, FO3_Essential = 0x00000002, @@ -79,7 +79,7 @@ namespace ESM4 }; // In FO4 flags seem to be the same. - enum ACBS_TES5 + enum ActorBaseFlagsTes5 { TES5_Female = 0x00000001, TES5_Essential = 0x00000002, @@ -103,7 +103,7 @@ namespace ESM4 }; // All FO3+ games. - enum Template_Flags + enum TemplateFlags { Template_UseTraits = 0x0001, // Destructible Object; Traits tab, including race, gender, height, weight, // voice type, death item; Sounds tab; Animation tab; Character Gen tabs diff --git a/components/esm4/loadqust.hpp b/components/esm4/loadqust.hpp index fa2f3e8f32..f791245fce 100644 --- a/components/esm4/loadqust.hpp +++ b/components/esm4/loadqust.hpp @@ -53,7 +53,7 @@ namespace ESM4 struct Quest { // NOTE: these values are for TES4 - enum Quest_Flags + enum QuestFlags { Flag_StartGameEnabled = 0x01, Flag_AllowRepeatConvTopic = 0x04, diff --git a/components/nif/physics.cpp b/components/nif/physics.cpp index 6368537e60..a053b62419 100644 --- a/components/nif/physics.cpp +++ b/components/nif/physics.cpp @@ -48,7 +48,7 @@ namespace Nif void bhkEntityCInfo::read(NIFStream* nif) { - mResponseType = static_cast(nif->get()); + mResponseType = static_cast(nif->get()); nif->skip(1); // Unused nif->read(mProcessContactDelay); } @@ -114,7 +114,7 @@ namespace Nif { if (nif->getBethVersion() >= 83) nif->skip(4); // Unused - mResponseType = static_cast(nif->get()); + mResponseType = static_cast(nif->get()); nif->skip(1); // Unused nif->read(mProcessContactDelay); } @@ -152,23 +152,23 @@ namespace Nif if (nif->getBethVersion() != NIFFile::BethVersion::BETHVER_FO4) nif->read(mPenetrationDepth); } - mMotionType = static_cast(nif->get()); + mMotionType = static_cast(nif->get()); if (nif->getBethVersion() < 83) - mDeactivatorType = static_cast(nif->get()); + mDeactivatorType = static_cast(nif->get()); else nif->read(mEnableDeactivation); - mSolverDeactivation = static_cast(nif->get()); + mSolverDeactivation = static_cast(nif->get()); if (nif->getBethVersion() == NIFFile::BethVersion::BETHVER_FO4) { nif->skip(1); nif->read(mPenetrationDepth); nif->read(mTimeFactor); nif->skip(4); - mResponseType = static_cast(nif->get()); + mResponseType = static_cast(nif->get()); nif->skip(1); // Unused nif->read(mProcessContactDelay); } - mQualityType = static_cast(nif->get()); + mQualityType = static_cast(nif->get()); if (nif->getBethVersion() >= 83) { nif->read(mAutoRemoveLevel); @@ -229,19 +229,19 @@ namespace Nif void bhkConstraintMotorCInfo::read(NIFStream* nif) { - mType = static_cast(nif->get()); + mType = static_cast(nif->get()); switch (mType) { - case hkMotorType::Motor_Position: + case HkMotorType::Motor_Position: mPositionMotor.read(nif); break; - case hkMotorType::Motor_Velocity: + case HkMotorType::Motor_Velocity: mVelocityMotor.read(nif); break; - case hkMotorType::Motor_SpringDamper: + case HkMotorType::Motor_SpringDamper: mSpringDamperMotor.read(nif); break; - case hkMotorType::Motor_None: + case HkMotorType::Motor_None: default: break; } @@ -378,26 +378,26 @@ namespace Nif void bhkMalleableConstraintCInfo::read(NIFStream* nif) { - mType = static_cast(nif->get()); + mType = static_cast(nif->get()); mInfo.read(nif); switch (mType) { - case hkConstraintType::BallAndSocket: + case HkConstraintType::BallAndSocket: mBallAndSocketInfo.read(nif); break; - case hkConstraintType::Hinge: + case HkConstraintType::Hinge: mHingeInfo.read(nif); break; - case hkConstraintType::LimitedHinge: + case HkConstraintType::LimitedHinge: mLimitedHingeInfo.read(nif); break; - case hkConstraintType::Prismatic: + case HkConstraintType::Prismatic: mPrismaticInfo.read(nif); break; - case hkConstraintType::Ragdoll: + case HkConstraintType::Ragdoll: mRagdollInfo.read(nif); break; - case hkConstraintType::StiffSpring: + case HkConstraintType::StiffSpring: mStiffSpringInfo.read(nif); break; default: @@ -417,29 +417,29 @@ namespace Nif void bhkWrappedConstraintData::read(NIFStream* nif) { - mType = static_cast(nif->get()); + mType = static_cast(nif->get()); mInfo.read(nif); switch (mType) { - case hkConstraintType::BallAndSocket: + case HkConstraintType::BallAndSocket: mBallAndSocketInfo.read(nif); break; - case hkConstraintType::Hinge: + case HkConstraintType::Hinge: mHingeInfo.read(nif); break; - case hkConstraintType::LimitedHinge: + case HkConstraintType::LimitedHinge: mLimitedHingeInfo.read(nif); break; - case hkConstraintType::Prismatic: + case HkConstraintType::Prismatic: mPrismaticInfo.read(nif); break; - case hkConstraintType::Ragdoll: + case HkConstraintType::Ragdoll: mRagdollInfo.read(nif); break; - case hkConstraintType::StiffSpring: + case HkConstraintType::StiffSpring: mStiffSpringInfo.read(nif); break; - case hkConstraintType::Malleable: + case HkConstraintType::Malleable: mMalleableInfo.read(nif); break; default: diff --git a/components/nif/physics.hpp b/components/nif/physics.hpp index 286c8cc353..0a2902de2e 100644 --- a/components/nif/physics.hpp +++ b/components/nif/physics.hpp @@ -74,7 +74,7 @@ namespace Nif void read(NIFStream* nif); }; - enum class hkResponseType : uint8_t + enum class HkResponseType : uint8_t { Response_Invalid = 0, Response_SimpleContact = 1, @@ -84,7 +84,7 @@ namespace Nif struct bhkEntityCInfo { - hkResponseType mResponseType; + HkResponseType mResponseType; uint16_t mProcessContactDelay; void read(NIFStream* nif); @@ -147,7 +147,7 @@ namespace Nif void read(NIFStream* nif); }; - enum class hkMotionType : uint8_t + enum class HkMotionType : uint8_t { Motion_Invalid = 0, Motion_Dynamic = 1, @@ -161,14 +161,14 @@ namespace Nif Motion_Character = 9 }; - enum class hkDeactivatorType : uint8_t + enum class HkDeactivatorType : uint8_t { Deactivator_Invalid = 0, Deactivator_Never = 1, Deactivator_Spatial = 2 }; - enum class hkSolverDeactivation : uint8_t + enum class HkSolverDeactivation : uint8_t { SolverDeactivation_Invalid = 0, SolverDeactivation_Off = 1, @@ -178,7 +178,7 @@ namespace Nif SolverDeactivation_Max = 5 }; - enum class hkQualityType : uint8_t + enum class HkQualityType : uint8_t { Quality_Invalid = 0, Quality_Fixed = 1, @@ -195,7 +195,7 @@ namespace Nif struct bhkRigidBodyCInfo { HavokFilter mHavokFilter; - hkResponseType mResponseType; + HkResponseType mResponseType; uint16_t mProcessContactDelay; osg::Vec4f mTranslation; osg::Quat mRotation; @@ -214,11 +214,11 @@ namespace Nif float mMaxLinearVelocity; float mMaxAngularVelocity; float mPenetrationDepth; - hkMotionType mMotionType; - hkDeactivatorType mDeactivatorType; + HkMotionType mMotionType; + HkDeactivatorType mDeactivatorType; bool mEnableDeactivation{ true }; - hkSolverDeactivation mSolverDeactivation; - hkQualityType mQualityType; + HkSolverDeactivation mSolverDeactivation; + HkQualityType mQualityType; uint8_t mAutoRemoveLevel; uint8_t mResponseModifierFlags; uint8_t mNumContactPointShapeKeys; @@ -244,7 +244,7 @@ namespace Nif void post(Reader& nif); }; - enum class hkMotorType : uint8_t + enum class HkMotorType : uint8_t { Motor_None = 0, Motor_Position = 1, @@ -287,7 +287,7 @@ namespace Nif struct bhkConstraintMotorCInfo { - hkMotorType mType; + HkMotorType mType; bhkPositionConstraintMotor mPositionMotor; bhkVelocityConstraintMotor mVelocityMotor; bhkSpringDamperConstraintMotor mSpringDamperMotor; @@ -384,7 +384,7 @@ namespace Nif void read(NIFStream* nif); }; - enum class hkConstraintType : uint32_t + enum class HkConstraintType : uint32_t { BallAndSocket = 0, Hinge = 1, @@ -397,7 +397,7 @@ namespace Nif struct bhkWrappedConstraintDataBase { - hkConstraintType mType; + HkConstraintType mType; bhkConstraintCInfo mInfo; bhkBallAndSocketConstraintCInfo mBallAndSocketInfo; bhkHingeConstraintCInfo mHingeInfo;