1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 18:35:20 +00:00

Merge pull request #2596 from akortunov/coverity

Fix some issues, found by CoverityScan
This commit is contained in:
Bret Curtis 2019-11-13 17:05:42 +01:00 committed by GitHub
commit 1c810b06fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 19 additions and 13 deletions

View File

@ -712,7 +712,7 @@ std::string creatureFlags(int flags)
if (flags & ESM::Creature::Respawn) properties += "Respawn ";
if (flags & ESM::Creature::Weapon) properties += "Weapon ";
if (flags & ESM::Creature::Essential) properties += "Essential ";
int unused = (0xFF ^
int unused = (0xFFFFFFFF ^
(ESM::Creature::Base|
ESM::Creature::Walks|
ESM::Creature::Swims|

View File

@ -1227,7 +1227,7 @@ void CSVRender::TerrainShapeMode::createNewLandData(const CSMWorld::CellCoordina
++averageDivider;
downCellSampleHeight = landDownShapePointer[ESM::Land::LAND_SIZE / 2];
if(paged->getCellAlteredHeight(cellLeftCoords, ESM::Land::LAND_SIZE / 2, 0))
if(paged->getCellAlteredHeight(cellDownCoords, ESM::Land::LAND_SIZE / 2, 0))
downCellSampleHeight += *paged->getCellAlteredHeight(cellDownCoords, ESM::Land::LAND_SIZE / 2, 0);
}
}

View File

@ -730,8 +730,12 @@ void CSVRender::TerrainTextureMode::setBrushShape(int brushShape)
selectionCenterY += value.second;
++selectionAmount;
}
selectionCenterX /= selectionAmount;
selectionCenterY /= selectionAmount;
if (selectionAmount != 0)
{
selectionCenterX /= selectionAmount;
selectionCenterY /= selectionAmount;
}
mCustomBrushShape.clear();
for (auto const& value: terrainSelection)

View File

@ -149,7 +149,7 @@ float BookWindowBase::adjustButton (char const * name)
Gui::ImageButton* button;
WindowBase::getWidget (button, name);
MyGUI::IntSize requested = button->getRequestedSize();
float scale = requested.height / button->getSize().height;
float scale = float(requested.height) / button->getSize().height;
MyGUI::IntSize newSize = requested;
newSize.width /= scale;
newSize.height /= scale;

View File

@ -21,6 +21,7 @@ namespace MWMechanics
Enchanting::Enchanting()
: mCastStyle(ESM::Enchantment::CastOnce)
, mSelfEnchanting(false)
, mWeaponType(-1)
{}
void Enchanting::setOldItem(const MWWorld::Ptr& oldItem)

View File

@ -539,7 +539,7 @@ std::string NpcAnimation::getShieldMesh(MWWorld::ConstPtr shield) const
{
const ESM::BodyPart *bodypart = 0;
bodypart = partStore.search(bodypartName);
if (bodypart->mData.mType != ESM::BodyPart::MT_Armor)
if (bodypart == nullptr || bodypart->mData.mType != ESM::BodyPart::MT_Armor)
return "";
else if (!bodypart->mModel.empty())
mesh = "meshes\\" + bodypart->mModel;

View File

@ -528,6 +528,8 @@ void Water::createSimpleWaterStateSet(osg::Node* node, float alpha)
// Add animated textures
std::vector<osg::ref_ptr<osg::Texture2D> > textures;
int frameCount = Fallback::Map::getInt("Water_SurfaceFrameCount");
frameCount = std::min(std::max(frameCount, 0), 320);
const std::string& texture = Fallback::Map::getString("Water_SurfaceTexture");
for (int i=0; i<frameCount; ++i)
{
@ -644,6 +646,8 @@ Water::~Water()
void Water::listAssetsToPreload(std::vector<std::string> &textures)
{
int frameCount = Fallback::Map::getInt("Water_SurfaceFrameCount");
frameCount = std::min(std::max(frameCount, 0), 320);
const std::string& texture = Fallback::Map::getString("Water_SurfaceTexture");
for (int i=0; i<frameCount; ++i)
{

View File

@ -49,7 +49,7 @@ void ESMStore::load(ESM::ESMReader &esm, Loading::Listener* listener)
std::string fname = mast.name;
int index = ~0;
for (int i = 0; i < esm.getIndex(); i++) {
const std::string &candidate = allPlugins->at(i).getContext().filename;
const std::string candidate = allPlugins->at(i).getContext().filename;
std::string fnamecandidate = boost::filesystem::path(candidate).filename().string();
if (Misc::StringUtils::ciEqual(fname, fnamecandidate)) {
index = i;

View File

@ -347,8 +347,6 @@ namespace Compiler
scanner.putbackName (name, loc);
return false;
}
return Parser::parseName (name, loc, scanner);
}
bool ExprParser::parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner)

View File

@ -301,7 +301,7 @@ namespace NifOsg
private:
Vec3Interpolator mData;
TargetColor mTargetColor;
TargetColor mTargetColor = Ambient;
};
class FlipController : public SceneUtil::StateSetUpdater, public SceneUtil::Controller

View File

@ -66,6 +66,8 @@ namespace SceneUtil
void ShadowManager::disableShadowsForStateSet(osg::ref_ptr<osg::StateSet> stateset)
{
int numberOfShadowMapsPerLight = Settings::Manager::getInt("number of shadow maps", "Shadows");
numberOfShadowMapsPerLight = std::max(1, std::min(numberOfShadowMapsPerLight, 8));
int baseShadowTextureUnit = 8 - numberOfShadowMapsPerLight;
osg::ref_ptr<osg::Image> fakeShadowMapImage = new osg::Image();

View File

@ -36,7 +36,6 @@ namespace Terrain
osg::ref_ptr<osg::Node> getChunk(float size, const osg::Vec2f& center, unsigned char lod, unsigned int lodFlags);
void setCullingActive(bool active) { mCullingActive = active; }
void setCompositeMapSize(unsigned int size) { mCompositeMapSize = size; }
void setCompositeMapLevel(float level) { mCompositeMapLevel = level; }
void setMaxCompositeGeometrySize(float maxCompGeometrySize) { mMaxCompGeometrySize = maxCompGeometrySize; }
@ -65,8 +64,6 @@ namespace Terrain
unsigned int mCompositeMapSize;
float mCompositeMapLevel;
float mMaxCompGeometrySize;
bool mCullingActive;
};
}