diff --git a/apps/opencs/view/render/terrainshapemode.cpp b/apps/opencs/view/render/terrainshapemode.cpp index 44f359c01..d356df8f3 100644 --- a/apps/opencs/view/render/terrainshapemode.cpp +++ b/apps/opencs/view/render/terrainshapemode.cpp @@ -1418,8 +1418,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 {};