Fix some issues, found by CoverityScan

pull/3024/head
Andrei Kortunov 4 years ago
parent 00503d86e1
commit 64ba81ecf2

@ -590,7 +590,9 @@ namespace MWMechanics
if (!actorState.isTurningToPlayer()) if (!actorState.isTurningToPlayer())
{ {
float angle = std::atan2(dir.x(), dir.y()); float from = dir.x();
float to = dir.y();
float angle = std::atan2(from, to);
actorState.setAngleToPlayer(angle); actorState.setAngleToPlayer(angle);
float deltaAngle = Misc::normalizeAngle(angle - actor.getRefData().getPosition().rot[2]); float deltaAngle = Misc::normalizeAngle(angle - actor.getRefData().getPosition().rot[2]);
if (!mSmoothMovement || std::abs(deltaAngle) > osg::DegreesToRadians(60.f)) if (!mSmoothMovement || std::abs(deltaAngle) > osg::DegreesToRadians(60.f))
@ -1723,7 +1725,7 @@ namespace MWMechanics
shouldAvoidCollision = true; shouldAvoidCollision = true;
else if (package->getTypeId() == AiPackageTypeId::Wander && giveWayWhenIdle) else if (package->getTypeId() == AiPackageTypeId::Wander && giveWayWhenIdle)
{ {
if (!dynamic_cast<const AiWander*>(package.get())->isStationary()) if (!static_cast<const AiWander*>(package.get())->isStationary())
shouldAvoidCollision = true; shouldAvoidCollision = true;
} }
else if (package->getTypeId() == AiPackageTypeId::Combat || package->getTypeId() == AiPackageTypeId::Pursue) else if (package->getTypeId() == AiPackageTypeId::Combat || package->getTypeId() == AiPackageTypeId::Pursue)

@ -142,6 +142,7 @@ namespace MWPhysics
{ {
PhysicsTaskScheduler::PhysicsTaskScheduler(float physicsDt, std::shared_ptr<btCollisionWorld> collisionWorld) PhysicsTaskScheduler::PhysicsTaskScheduler(float physicsDt, std::shared_ptr<btCollisionWorld> collisionWorld)
: mPhysicsDt(physicsDt) : mPhysicsDt(physicsDt)
, mTimeAccum(0.f)
, mCollisionWorld(std::move(collisionWorld)) , mCollisionWorld(std::move(collisionWorld))
, mNumJobs(0) , mNumJobs(0)
, mRemainingSteps(0) , mRemainingSteps(0)

@ -66,6 +66,9 @@ namespace MWRender
mIsNearest(false), mIsNearest(false),
mHeight(124.f), mHeight(124.f),
mBaseCameraDistance(Settings::Manager::getFloat("third person camera distance", "Camera")), mBaseCameraDistance(Settings::Manager::getFloat("third person camera distance", "Camera")),
mPitch(0.f),
mYaw(0.f),
mRoll(0.f),
mVanityToggleQueued(false), mVanityToggleQueued(false),
mVanityToggleQueuedValue(false), mVanityToggleQueuedValue(false),
mViewModeToggleQueued(false), mViewModeToggleQueued(false),
@ -81,6 +84,9 @@ namespace MWRender
mDynamicCameraDistanceEnabled(false), mDynamicCameraDistanceEnabled(false),
mShowCrosshairInThirdPersonMode(false), mShowCrosshairInThirdPersonMode(false),
mHeadBobbingEnabled(Settings::Manager::getBool("head bobbing", "Camera")), mHeadBobbingEnabled(Settings::Manager::getBool("head bobbing", "Camera")),
mHeadBobbingOffset(0.f),
mHeadBobbingWeight(0.f),
mTotalMovement(0.f),
mDeferredRotation(osg::Vec3f()), mDeferredRotation(osg::Vec3f()),
mDeferredRotationDisabled(false) mDeferredRotationDisabled(false)
{ {

@ -74,8 +74,8 @@ namespace MWRender
bool mHeadBobbingEnabled; bool mHeadBobbingEnabled;
float mHeadBobbingOffset; float mHeadBobbingOffset;
float mHeadBobbingWeight = 0; // Value from 0 to 1 for smooth enabling/disabling. float mHeadBobbingWeight; // Value from 0 to 1 for smooth enabling/disabling.
float mTotalMovement = 0; // Needed for head bobbing. float mTotalMovement; // Needed for head bobbing.
void updateHeadBobbing(float duration); void updateHeadBobbing(float duration);
void updateFocalPointOffset(float duration); void updateFocalPointOffset(float duration);

@ -65,6 +65,9 @@ namespace MWSound
, mUnderwaterSound(nullptr) , mUnderwaterSound(nullptr)
, mNearWaterSound(nullptr) , mNearWaterSound(nullptr)
, mPlaybackPaused(false) , mPlaybackPaused(false)
, mTimePassed(0.f)
, mLastCell(nullptr)
, mCurrentRegionSound(nullptr)
{ {
mBufferCacheMin = std::max(Settings::Manager::getInt("buffer cache min", "Sound"), 1); mBufferCacheMin = std::max(Settings::Manager::getInt("buffer cache min", "Sound"), 1);
mBufferCacheMax = std::max(Settings::Manager::getInt("buffer cache max", "Sound"), 1); mBufferCacheMax = std::max(Settings::Manager::getInt("buffer cache max", "Sound"), 1);

@ -116,9 +116,9 @@ namespace MWSound
RegionSoundSelector mRegionSoundSelector; RegionSoundSelector mRegionSoundSelector;
float mTimePassed = 0; float mTimePassed;
const ESM::Cell *mLastCell = nullptr; const ESM::Cell *mLastCell;
Sound* mCurrentRegionSound; Sound* mCurrentRegionSound;

@ -331,9 +331,10 @@ namespace ESM
std::copy(land.mWnam, land.mWnam + LAND_GLOBAL_MAP_LOD_SIZE, mWnam); std::copy(land.mWnam, land.mWnam + LAND_GLOBAL_MAP_LOD_SIZE, mWnam);
} }
Land& Land::operator= (Land land) Land& Land::operator= (const Land& land)
{ {
swap (land); Land tmp(land);
swap(tmp);
return *this; return *this;
} }

@ -148,7 +148,7 @@ struct Land
Land (const Land& land); Land (const Land& land);
Land& operator= (Land land); Land& operator= (const Land& land);
void swap (Land& land); void swap (Land& land);

Loading…
Cancel
Save