1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-27 21:35:24 +00:00

Merge branch 'fix_tidy_warnings' into 'master'

Fix several Clang-Tidy warnings

See merge request OpenMW/openmw!2107
This commit is contained in:
psi29a 2022-07-06 13:47:59 +00:00
commit 1ef8ca1f27
9 changed files with 35 additions and 25 deletions

View File

@ -759,13 +759,13 @@ void Launcher::DataFilesPage::slotAddonDataChanged()
}
// Mutex lock to run reloadCells synchronously.
std::mutex _reloadCellsMutex;
static std::mutex reloadCellsMutex;
void Launcher::DataFilesPage::reloadCells(QStringList selectedFiles)
{
// Use a mutex lock so that we can prevent two threads from executing the rest of this code at the same time
// Based on https://stackoverflow.com/a/5429695/531762
std::unique_lock<std::mutex> lock(_reloadCellsMutex);
std::unique_lock<std::mutex> lock(reloadCellsMutex);
// The following code will run only if there is not another thread currently running it
CellNameLoader cellNameLoader;

View File

@ -284,14 +284,14 @@ namespace CSVRender
osg::ref_ptr<osg::Geometry> geometry (new osg::Geometry);
osg::Vec3Array *vertices = new osg::Vec3Array;
int resolution = 32;
constexpr int resolution = 32;
float radiusPerResolution = radius / resolution;
float reciprocalResolution = 1.0f / resolution;
float doubleReciprocalRes = reciprocalResolution * 2;
osg::Vec4Array *colours = new osg::Vec4Array;
for (float i = 0.0; i <= resolution; i += 2)
for (int i = 0; i <= resolution; i += 2)
{
float iShifted = (static_cast<float>(i) - resolution / 2.0f); // i - 16 = -16 ... 16
float xPercentile = iShifted * doubleReciprocalRes;

View File

@ -83,16 +83,16 @@ namespace
setVisible (visible);
}
void adviseButtonClick (char const * name, void (JournalWindowImpl::*Handler) (MyGUI::Widget* _sender))
void adviseButtonClick (char const * name, void (JournalWindowImpl::*handler)(MyGUI::Widget*))
{
getWidget <MyGUI::Widget> (name) ->
eventMouseButtonClick += newDelegate(this, Handler);
eventMouseButtonClick += newDelegate(this, handler);
}
void adviseKeyPress (char const * name, void (JournalWindowImpl::*Handler) (MyGUI::Widget* _sender, MyGUI::KeyCode key, MyGUI::Char character))
void adviseKeyPress (char const * name, void (JournalWindowImpl::*handler)(MyGUI::Widget*, MyGUI::KeyCode, MyGUI::Char))
{
getWidget <MyGUI::Widget> (name) ->
eventKeyButtonPressed += newDelegate(this, Handler);
eventKeyButtonPressed += newDelegate(this, handler);
}
MWGui::BookPage* getPage (char const * name)

View File

@ -60,7 +60,7 @@ namespace MWInput
SDL_ControllerDeviceEvent evt;
evt.which = i;
static const int fakeDeviceID = 1;
controllerAdded(fakeDeviceID, evt);
ControllerManager::controllerAdded(fakeDeviceID, evt);
Log(Debug::Info) << "Detected game controller: " << SDL_GameControllerNameForIndex(i);
}
else

View File

@ -243,6 +243,13 @@ float getFallDamage(const MWWorld::Ptr& ptr, float fallHeight)
return 0.f;
}
bool isRealWeapon(int weaponType)
{
return weaponType != ESM::Weapon::HandToHand
&& weaponType != ESM::Weapon::Spell
&& weaponType != ESM::Weapon::None;
}
}
namespace MWMechanics
@ -486,8 +493,7 @@ void CharacterController::onClose() const
std::string CharacterController::getWeaponAnimation(int weaponType) const
{
std::string weaponGroup = getWeaponType(weaponType)->mLongGroup;
bool isRealWeapon = weaponType != ESM::Weapon::HandToHand && weaponType != ESM::Weapon::Spell && weaponType != ESM::Weapon::None;
if (isRealWeapon && !mAnimation->hasAnimation(weaponGroup))
if (isRealWeapon(weaponType) && !mAnimation->hasAnimation(weaponGroup))
{
static const std::string oneHandFallback = getWeaponType(ESM::Weapon::LongBladeOneHand)->mLongGroup;
static const std::string twoHandFallback = getWeaponType(ESM::Weapon::LongBladeTwoHand)->mLongGroup;
@ -497,7 +503,7 @@ std::string CharacterController::getWeaponAnimation(int weaponType) const
// For real two-handed melee weapons use 2h swords animations as fallback, otherwise use the 1h ones
if (weapInfo->mFlags & ESM::WeaponType::TwoHanded && weapInfo->mWeaponClass == ESM::WeaponType::Melee)
weaponGroup = twoHandFallback;
else if (isRealWeapon)
else
weaponGroup = oneHandFallback;
}
else if (weaponType == ESM::Weapon::HandToHand && !mPtr.getClass().isBipedal(mPtr))
@ -515,8 +521,7 @@ std::string CharacterController::getWeaponShortGroup(int weaponType) const
std::string CharacterController::fallbackShortWeaponGroup(const std::string& baseGroupName, MWRender::Animation::BlendMask* blendMask) const
{
bool isRealWeapon = mWeaponType != ESM::Weapon::HandToHand && mWeaponType != ESM::Weapon::Spell && mWeaponType != ESM::Weapon::None;
if (!isRealWeapon)
if (!isRealWeapon(mWeaponType))
{
if (blendMask != nullptr)
*blendMask = MWRender::Animation::BlendMask_LowerBody;

View File

@ -1838,7 +1838,7 @@ namespace MWRender
mObjectRoot->accept(visitor);
}
if (ptr.getRefData().getCustomData() != nullptr && canBeHarvested())
if (ptr.getRefData().getCustomData() != nullptr && ObjectAnimation::canBeHarvested())
{
const MWWorld::ContainerStore& store = ptr.getClass().getContainerStore(ptr);
if (!store.hasVisibleItems())

View File

@ -30,7 +30,7 @@ DebugDrawer::DebugDrawer(osg::ref_ptr<osg::Group> parentNode, btCollisionWorld *
: mParentNode(parentNode),
mWorld(world)
{
setDebugMode(debugMode);
DebugDrawer::setDebugMode(debugMode);
}
void DebugDrawer::createGeometry()

View File

@ -179,7 +179,9 @@ namespace DetourNavigator
, mInsertShape(*mDb, DbQueries::InsertShape {})
, mVacuum(*mDb, DbQueries::Vacuum {})
{
const auto dbPageSize = getPageSize(*mDb);
const std::uint64_t dbPageSize = getPageSize(*mDb);
if (dbPageSize == 0)
throw std::runtime_error("NavMeshDb page size is zero");
setMaxPageCount(*mDb, maxFileSize / dbPageSize + static_cast<std::uint64_t>((maxFileSize % dbPageSize) != 0));
}

View File

@ -4,6 +4,7 @@
#include <vector>
#include <variant>
#include <sstream>
#include <tuple>
#include <BulletCollision/CollisionShapes/btBoxShape.h>
#include <BulletCollision/CollisionShapes/btTriangleMesh.h>
@ -76,7 +77,9 @@ void fillTriangleMesh(btTriangleMesh& mesh, const Nif::NiTriStripsData& data, co
if (strip.size() < 3)
continue;
unsigned short a = strip[0], b = strip[0], c = strip[1];
unsigned short a;
unsigned short b = strip[0];
unsigned short c = strip[1];
for (size_t i = 2; i < strip.size(); i++)
{
a = b;
@ -203,7 +206,7 @@ osg::ref_ptr<Resource::BulletShape> BulletNifLoader::load(const Nif::File& nif)
btTransform transform = btTransform::getIdentity();
transform.setOrigin(center);
compound->addChildShape(transform, boxShape.get());
boxShape.release();
std::ignore = boxShape.release();
mShape->mCollisionShape.reset(compound.release());
return mShape;
@ -229,21 +232,21 @@ osg::ref_ptr<Resource::BulletShape> BulletNifLoader::load(const Nif::File& nif)
trans.setIdentity();
std::unique_ptr<btCollisionShape> child = std::make_unique<Resource::TriangleMeshShape>(mStaticMesh.get(), true);
mCompoundShape->addChildShape(trans, child.get());
child.release();
mStaticMesh.release();
std::ignore = child.release();
std::ignore = mStaticMesh.release();
}
mShape->mCollisionShape = std::move(mCompoundShape);
}
else if (mStaticMesh != nullptr && mStaticMesh->getNumTriangles() > 0)
{
mShape->mCollisionShape.reset(new Resource::TriangleMeshShape(mStaticMesh.get(), true));
mStaticMesh.release();
std::ignore = mStaticMesh.release();
}
if (mAvoidStaticMesh != nullptr && mAvoidStaticMesh->getNumTriangles() > 0)
{
mShape->mAvoidCollisionShape.reset(new Resource::TriangleMeshShape(mAvoidStaticMesh.get(), false));
mAvoidStaticMesh.release();
std::ignore = mAvoidStaticMesh.release();
}
return mShape;
@ -408,7 +411,7 @@ void BulletNifLoader::handleNiTriShape(const Nif::NiGeometry& niGeometry, const
mCompoundShape.reset(new btCompoundShape);
auto childShape = std::make_unique<Resource::TriangleMeshShape>(childMesh.get(), true);
childMesh.release();
std::ignore = childMesh.release();
float scale = niGeometry.trafo.scale;
for (const Nif::Parent* parent = nodeParent; parent != nullptr; parent = parent->mParent)
@ -422,7 +425,7 @@ void BulletNifLoader::handleNiTriShape(const Nif::NiGeometry& niGeometry, const
mShape->mAnimatedShapes.emplace(niGeometry.recIndex, mCompoundShape->getNumChildShapes());
mCompoundShape->addChildShape(trans, childShape.get());
childShape.release();
std::ignore = childShape.release();
}
else if (avoid)
fillTriangleMesh(mAvoidStaticMesh, niGeometry, transform);