diff --git a/apps/opencs/view/render/terrainshapemode.cpp b/apps/opencs/view/render/terrainshapemode.cpp index 1e5b70353a..77a178c2a1 100644 --- a/apps/opencs/view/render/terrainshapemode.cpp +++ b/apps/opencs/view/render/terrainshapemode.cpp @@ -1439,8 +1439,12 @@ void CSVRender::TerrainShapeMode::setBrushShape(CSVWidget::BrushShape brushShape selectionCenterY = selectionCenterY + value.second; ++selectionAmount; } - selectionCenterX = selectionCenterX / selectionAmount; - selectionCenterY = selectionCenterY / selectionAmount; + + if (selectionAmount != 0) + { + selectionCenterX /= selectionAmount; + selectionCenterY /= selectionAmount; + } mCustomBrushShape.clear(); std::pair differentialPos {}; diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index a1b4308cec..6d230d36e2 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -527,9 +527,7 @@ void Water::createSimpleWaterStateSet(osg::Node* node, float alpha) // Add animated textures std::vector > textures; - int frameCount = Fallback::Map::getInt("Water_SurfaceFrameCount"); - frameCount = std::min(std::max(frameCount, 0), 320); - + int frameCount = std::max(0, std::min(Fallback::Map::getInt("Water_SurfaceFrameCount"), 320)); const std::string& texture = Fallback::Map::getString("Water_SurfaceTexture"); for (int i=0; i &textures) { - int frameCount = Fallback::Map::getInt("Water_SurfaceFrameCount"); - frameCount = std::min(std::max(frameCount, 0), 320); - + int frameCount = std::max(0, std::min(Fallback::Map::getInt("Water_SurfaceFrameCount"), 320)); const std::string& texture = Fallback::Map::getString("Water_SurfaceTexture"); for (int i=0; i