Fix an another portion of Coverity warnings

pull/593/head
Andrei Kortunov 4 years ago
parent 57b501ad13
commit 987b231fdd

@ -67,7 +67,7 @@ namespace MWPhysics
if(attempt == 1) if(attempt == 1)
tracerDest = tracerPos + toMove; tracerDest = tracerPos + toMove;
else if (!firstIteration || !sDoExtraStairHacks) // first attempt failed and not on first movement solver iteration, can't retry -- or we have extra hacks disabled else if (!sDoExtraStairHacks) // early out if we have extra hacks disabled
{ {
return false; return false;
} }

@ -81,7 +81,7 @@ MWWorld::ResolutionListener::~ResolutionListener()
} }
catch(const std::exception& e) catch(const std::exception& e)
{ {
Log(Debug::Error) << "Failed to clear temporary container contents of " << mStore.mPtr.get<ESM::Container>()->mBase->mId << ": " << e.what(); Log(Debug::Error) << "Failed to clear temporary container contents: " << e.what();
} }
} }

@ -703,7 +703,10 @@ namespace SceneUtil
{ {
public: public:
LightManagerStateAttribute() LightManagerStateAttribute()
: mLightManager(nullptr) {} : mLightManager(nullptr)
, mInitLayout(false)
{
}
LightManagerStateAttribute(LightManager* lightManager) LightManagerStateAttribute(LightManager* lightManager)
: mLightManager(lightManager) : mLightManager(lightManager)
@ -720,7 +723,7 @@ namespace SceneUtil
} }
LightManagerStateAttribute(const LightManagerStateAttribute& copy, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) LightManagerStateAttribute(const LightManagerStateAttribute& copy, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY)
: osg::StateAttribute(copy,copyop), mLightManager(copy.mLightManager) {} : osg::StateAttribute(copy,copyop), mLightManager(copy.mLightManager), mInitLayout(copy.mInitLayout) {}
int compare(const StateAttribute &sa) const override int compare(const StateAttribute &sa) const override
{ {
@ -874,7 +877,7 @@ namespace SceneUtil
hasLoggedWarnings = true; hasLoggedWarnings = true;
} }
int targetLights = Settings::Manager::getInt("max lights", "Shaders"); int targetLights = std::clamp(Settings::Manager::getInt("max lights", "Shaders"), mMaxLightsLowerLimit, mMaxLightsUpperLimit);
if (!supportsUBO || !supportsGPU4 || lightingMethod == LightingMethod::PerObjectUniform) if (!supportsUBO || !supportsGPU4 || lightingMethod == LightingMethod::PerObjectUniform)
initPerObjectUniform(targetLights); initPerObjectUniform(targetLights);
@ -954,7 +957,8 @@ namespace SceneUtil
if (usingFFP()) if (usingFFP())
return; return;
setMaxLights(std::clamp(Settings::Manager::getInt("max lights", "Shaders"), mMaxLightsLowerLimit, mMaxLightsUpperLimit)); int targetLights = std::clamp(Settings::Manager::getInt("max lights", "Shaders"), mMaxLightsLowerLimit, mMaxLightsUpperLimit);
setMaxLights(targetLights);
if (getLightingMethod() == LightingMethod::PerObjectUniform) if (getLightingMethod() == LightingMethod::PerObjectUniform)
{ {
@ -1033,7 +1037,7 @@ namespace SceneUtil
auto* stateset = getOrCreateStateSet(); auto* stateset = getOrCreateStateSet();
setLightingMethod(LightingMethod::PerObjectUniform); setLightingMethod(LightingMethod::PerObjectUniform);
setMaxLights(std::clamp(targetLights, mMaxLightsLowerLimit, mMaxLightsUpperLimit)); setMaxLights(targetLights);
// ensures sunlight element in our uniform array is updated when there are no point lights in scene // ensures sunlight element in our uniform array is updated when there are no point lights in scene
stateset->setAttributeAndModes(new LightStateAttributePerObjectUniform({}, this), osg::StateAttribute::ON); stateset->setAttributeAndModes(new LightStateAttributePerObjectUniform({}, this), osg::StateAttribute::ON);
@ -1043,7 +1047,7 @@ namespace SceneUtil
void LightManager::initSingleUBO(int targetLights) void LightManager::initSingleUBO(int targetLights)
{ {
setLightingMethod(LightingMethod::SingleUBO); setLightingMethod(LightingMethod::SingleUBO);
setMaxLights(std::clamp(targetLights, mMaxLightsLowerLimit, mMaxLightsUpperLimit)); setMaxLights(targetLights);
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {

@ -361,14 +361,10 @@ InputWrapper::InputWrapper(SDL_Window* window, osg::ref_ptr<osgViewer::Viewer> v
/// \brief Package mouse and mousewheel motions into a single event /// \brief Package mouse and mousewheel motions into a single event
MouseMotionEvent InputWrapper::_packageMouseMotion(const SDL_Event &evt) MouseMotionEvent InputWrapper::_packageMouseMotion(const SDL_Event &evt)
{ {
MouseMotionEvent pack_evt; MouseMotionEvent pack_evt = {};
pack_evt.x = mMouseX; pack_evt.x = mMouseX;
pack_evt.xrel = 0;
pack_evt.y = mMouseY; pack_evt.y = mMouseY;
pack_evt.yrel = 0;
pack_evt.z = mMouseZ; pack_evt.z = mMouseZ;
pack_evt.zrel = 0;
pack_evt.timestamp = 0;
if(evt.type == SDL_MOUSEMOTION) if(evt.type == SDL_MOUSEMOTION)
{ {

Loading…
Cancel
Save