From e9ed0211c9ef71b63c924c14727bd02a89425290 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 28 Sep 2014 12:44:47 +0200 Subject: [PATCH] Attempt to fix Clang warnings --- apps/openmw/mwgui/savegamedialog.cpp | 3 ++- apps/openmw/mwgui/windowbase.cpp | 2 ++ apps/openmw/mwmechanics/aiescort.cpp | 6 +++++- apps/openmw/mwmechanics/autocalcspell.cpp | 2 +- apps/openmw/mwmechanics/character.cpp | 2 +- apps/openmw/mwworld/physicssystem.cpp | 2 -- apps/openmw/mwworld/weather.cpp | 3 ++- apps/openmw/mwworld/worldimp.cpp | 2 +- components/esmterrain/storage.cpp | 4 ++-- components/widgets/box.cpp | 26 +++++++++++++++++++---- 10 files changed, 38 insertions(+), 14 deletions(-) diff --git a/apps/openmw/mwgui/savegamedialog.cpp b/apps/openmw/mwgui/savegamedialog.cpp index 3920a5dcb..66c7a9238 100644 --- a/apps/openmw/mwgui/savegamedialog.cpp +++ b/apps/openmw/mwgui/savegamedialog.cpp @@ -322,7 +322,8 @@ namespace MWGui if (i == pos) mCurrentSlot = &*it; } - assert(mCurrentSlot && "Can't find selected slot"); + if (!mCurrentSlot) + throw std::runtime_error("Can't find selected slot"); std::stringstream text; time_t time = mCurrentSlot->mTimeStamp; diff --git a/apps/openmw/mwgui/windowbase.cpp b/apps/openmw/mwgui/windowbase.cpp index 432510a3e..9c12b04ef 100644 --- a/apps/openmw/mwgui/windowbase.cpp +++ b/apps/openmw/mwgui/windowbase.cpp @@ -76,6 +76,8 @@ void WindowModal::close() NoDrop::NoDrop(DragAndDrop *drag, MyGUI::Widget *widget) : mDrag(drag), mWidget(widget), mTransparent(false) { + if (!mWidget) + throw std::runtime_error("NoDrop needs a non-NULL widget!"); } void NoDrop::onFrame(float dt) diff --git a/apps/openmw/mwmechanics/aiescort.cpp b/apps/openmw/mwmechanics/aiescort.cpp index 98fc64090..324bef322 100644 --- a/apps/openmw/mwmechanics/aiescort.cpp +++ b/apps/openmw/mwmechanics/aiescort.cpp @@ -92,7 +92,11 @@ namespace MWMechanics if(distanceBetweenResult <= mMaxDist * mMaxDist) { - if(pathTo(actor,ESM::Pathgrid::Point(mX,mY,mZ),duration)) //Returns true on path complete + ESM::Pathgrid::Point point(mX,mY,mZ); + point.mAutogenerated = 0; + point.mConnectionNum = 0; + point.mUnknown = 0; + if(pathTo(actor,point,duration)) //Returns true on path complete return true; mMaxDist = 450; } diff --git a/apps/openmw/mwmechanics/autocalcspell.cpp b/apps/openmw/mwmechanics/autocalcspell.cpp index 255decdf7..01447c6e4 100644 --- a/apps/openmw/mwmechanics/autocalcspell.cpp +++ b/apps/openmw/mwmechanics/autocalcspell.cpp @@ -220,7 +220,7 @@ namespace MWMechanics if (spell->mData.mFlags & ESM::Spell::F_Always) return 100.f; - float skillTerm; + float skillTerm = 0; if (effectiveSchool != -1) skillTerm = 2.f * actorSkills[mapSchoolToSkill(effectiveSchool)]; else diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 8f1a8f718..7c7ea0c95 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -1611,7 +1611,7 @@ void CharacterController::update(float duration) if(mMovementAnimationControlled && mPtr.getClass().isActor()) world->queueMovement(mPtr, moved); } - else if (mAnimation) + else mAnimation->updateEffects(duration); mSkipAnim = false; diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 31d52e39d..d5267b8cf 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -385,7 +385,6 @@ namespace MWWorld if(tracer.mFraction >= 1.0f) { newPosition = tracer.mEndPos; // ok to move, so set newPosition - remainingTime *= (1.0f-tracer.mFraction); // FIXME: remainingTime is no longer used so don't set it? break; } else @@ -406,7 +405,6 @@ namespace MWWorld // precision can be lost due to any math Bullet does internally). Since we // aren't performing any collision detection, we want to reject the next // position, so that we don't slowly move inside another object. - remainingTime *= (1.0f-tracer.mFraction); // FIXME: remainingTime is no longer used so don't set it? break; } diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 613fd712f..525352e7f 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -498,7 +498,8 @@ void WeatherManager::update(float duration) else if (sound == 1) soundName = &mThunderSoundID1; else if (sound == 2) soundName = &mThunderSoundID2; else if (sound == 3) soundName = &mThunderSoundID3; - MWBase::Environment::get().getSoundManager()->playSound(*soundName, 1.0, 1.0); + if (soundName) + MWBase::Environment::get().getSoundManager()->playSound(*soundName, 1.0, 1.0); mThunderSoundDelay = 1000; } diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index c49f1f483..1f3cf01e1 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1045,7 +1045,7 @@ namespace MWWorld CellStore *currCell = ptr.isInCell() ? ptr.getCell() : NULL; // currCell == NULL should only happen for player, during initial startup bool isPlayer = ptr == mPlayer->getPlayer(); - bool haveToMove = isPlayer || mWorldScene->isCellActive(*currCell); + bool haveToMove = isPlayer || (currCell && mWorldScene->isCellActive(*currCell)); if (currCell != newCell) { diff --git a/components/esmterrain/storage.cpp b/components/esmterrain/storage.cpp index 585c1495d..c4152533e 100644 --- a/components/esmterrain/storage.cpp +++ b/components/esmterrain/storage.cpp @@ -147,8 +147,8 @@ namespace ESMTerrain Ogre::Vector3 normal; Ogre::ColourValue color; - float vertY; - float vertX; + float vertY = 0; + float vertX = 0; float vertY_ = 0; // of current cell corner for (int cellY = startY; cellY < startY + std::ceil(size); ++cellY) diff --git a/components/widgets/box.cpp b/components/widgets/box.cpp index e1c148271..0ac2ff7fd 100644 --- a/components/widgets/box.cpp +++ b/components/widgets/box.cpp @@ -197,8 +197,17 @@ namespace Gui MyGUI::IntCoord widgetCoord; widgetCoord.left = curX; widgetCoord.top = mPadding + (getSize().height-mPadding*2 - height) / 2; - int width = sizes[i].second ? sizes[i].first.width + (getSize().width-mPadding*2 - total_width)/h_stretched_count - : sizes[i].first.width; + + int width = 0; + if (sizes[i].second) + { + if (h_stretched_count == 0) + throw std::logic_error("unexpected"); + width = sizes[i].first.width + (getSize().width-mPadding*2 - total_width)/h_stretched_count; + } + else + width = sizes[i].first.width; + widgetCoord.width = width; widgetCoord.height = height; w->setCoord(widgetCoord); @@ -334,8 +343,17 @@ namespace Gui MyGUI::IntCoord widgetCoord; widgetCoord.top = curY; widgetCoord.left = mPadding + (getSize().width-mPadding*2 - width) / 2; - int height = sizes[i].second ? sizes[i].first.height + (getSize().height-mPadding*2 - total_height)/v_stretched_count - : sizes[i].first.height; + + int height = 0; + if (sizes[i].second) + { + if (v_stretched_count == 0) + throw std::logic_error("unexpected"); + height = sizes[i].first.height + (getSize().height-mPadding*2 - total_height)/v_stretched_count; + } + else + height = sizes[i].first.height; + widgetCoord.height = height; widgetCoord.width = width; w->setCoord(widgetCoord);