mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-30 02:56:44 +00:00 
			
		
		
		
	Merge pull request #3024 from akortunov/coverity
Fix some issues, found by CoverityScan
This commit is contained in:
		
						commit
						0eaac4b522
					
				
					 9 changed files with 29 additions and 10 deletions
				
			
		|  | @ -590,7 +590,9 @@ namespace MWMechanics | |||
| 
 | ||||
|         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); | ||||
|             float deltaAngle = Misc::normalizeAngle(angle - actor.getRefData().getPosition().rot[2]); | ||||
|             if (!mSmoothMovement || std::abs(deltaAngle) > osg::DegreesToRadians(60.f)) | ||||
|  | @ -1723,7 +1725,7 @@ namespace MWMechanics | |||
|                     shouldAvoidCollision = true; | ||||
|                 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; | ||||
|                 } | ||||
|                 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) | ||||
|           : mPhysicsDt(physicsDt) | ||||
|           , mTimeAccum(0.f) | ||||
|           , mCollisionWorld(std::move(collisionWorld)) | ||||
|           , mNumJobs(0) | ||||
|           , mRemainingSteps(0) | ||||
|  |  | |||
|  | @ -66,6 +66,9 @@ namespace MWRender | |||
|       mIsNearest(false), | ||||
|       mHeight(124.f), | ||||
|       mBaseCameraDistance(Settings::Manager::getFloat("third person camera distance", "Camera")), | ||||
|       mPitch(0.f), | ||||
|       mYaw(0.f), | ||||
|       mRoll(0.f), | ||||
|       mVanityToggleQueued(false), | ||||
|       mVanityToggleQueuedValue(false), | ||||
|       mViewModeToggleQueued(false), | ||||
|  | @ -81,6 +84,9 @@ namespace MWRender | |||
|       mDynamicCameraDistanceEnabled(false), | ||||
|       mShowCrosshairInThirdPersonMode(false), | ||||
|       mHeadBobbingEnabled(Settings::Manager::getBool("head bobbing", "Camera")), | ||||
|       mHeadBobbingOffset(0.f), | ||||
|       mHeadBobbingWeight(0.f), | ||||
|       mTotalMovement(0.f), | ||||
|       mDeferredRotation(osg::Vec3f()), | ||||
|       mDeferredRotationDisabled(false) | ||||
|     { | ||||
|  |  | |||
|  | @ -74,8 +74,8 @@ namespace MWRender | |||
| 
 | ||||
|         bool mHeadBobbingEnabled; | ||||
|         float mHeadBobbingOffset; | ||||
|         float mHeadBobbingWeight = 0; // Value from 0 to 1 for smooth enabling/disabling.
 | ||||
|         float mTotalMovement = 0; // Needed for head bobbing.
 | ||||
|         float mHeadBobbingWeight; // Value from 0 to 1 for smooth enabling/disabling.
 | ||||
|         float mTotalMovement; // Needed for head bobbing.
 | ||||
|         void updateHeadBobbing(float duration); | ||||
| 
 | ||||
|         void updateFocalPointOffset(float duration); | ||||
|  |  | |||
|  | @ -65,6 +65,9 @@ namespace MWSound | |||
|         , mUnderwaterSound(nullptr) | ||||
|         , mNearWaterSound(nullptr) | ||||
|         , mPlaybackPaused(false) | ||||
|         , mTimePassed(0.f) | ||||
|         , mLastCell(nullptr) | ||||
|         , mCurrentRegionSound(nullptr) | ||||
|     { | ||||
|         mBufferCacheMin = std::max(Settings::Manager::getInt("buffer cache min", "Sound"), 1); | ||||
|         mBufferCacheMax = std::max(Settings::Manager::getInt("buffer cache max", "Sound"), 1); | ||||
|  |  | |||
|  | @ -116,9 +116,9 @@ namespace MWSound | |||
| 
 | ||||
|         RegionSoundSelector mRegionSoundSelector; | ||||
| 
 | ||||
|         float mTimePassed = 0; | ||||
|         float mTimePassed; | ||||
| 
 | ||||
|         const ESM::Cell *mLastCell = nullptr; | ||||
|         const ESM::Cell *mLastCell; | ||||
| 
 | ||||
|         Sound* mCurrentRegionSound; | ||||
| 
 | ||||
|  |  | |||
|  | @ -143,8 +143,14 @@ static void gdb_info(pid_t pid) | |||
|     FILE *f; | ||||
|     int fd; | ||||
| 
 | ||||
|     /* Create a temp file to put gdb commands into */ | ||||
|     /*
 | ||||
|      * Create a temp file to put gdb commands into. | ||||
|      * Note: POSIX.1-2008 declares that the file should be already created with mode 0600 by default. | ||||
|      * Modern systems implement it and and suggest to do not touch masks in multithreaded applications. | ||||
|      * So CoverityScan warning is valid only for ancient versions of stdlib. | ||||
|     */ | ||||
|     strcpy(respfile, "/tmp/gdb-respfile-XXXXXX"); | ||||
|     // coverity[secure_temp]
 | ||||
|     if((fd=mkstemp(respfile)) >= 0 && (f=fdopen(fd, "w")) != nullptr) | ||||
|     { | ||||
|         fprintf(f, "attach %d\n" | ||||
|  |  | |||
|  | @ -331,9 +331,10 @@ namespace ESM | |||
|         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; | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -148,7 +148,7 @@ struct Land | |||
| 
 | ||||
|         Land (const Land& land); | ||||
| 
 | ||||
|         Land& operator= (Land land); | ||||
|         Land& operator= (const Land& land); | ||||
| 
 | ||||
|         void swap (Land& land); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue