diff --git a/lib/rmg/CRmgTemplateZone.cpp b/lib/rmg/CRmgTemplateZone.cpp index 6f058f456..903307813 100644 --- a/lib/rmg/CRmgTemplateZone.cpp +++ b/lib/rmg/CRmgTemplateZone.cpp @@ -673,8 +673,9 @@ bool CRmgTemplateZone::createTreasurePile (CMapGenerator* gen, int3 &pos) } ui32 desiredValue = gen->rand.nextInt(minValue, maxValue); //quantize value to let objects with value equal to max spawn too - float quant = (maxValue - minValue)/4.f; - desiredValue = (boost::math::round(desiredValue / quant)) * quant; + ui32 diff = maxValue - minValue; + float quant = (float)diff / 4.f; + desiredValue = (boost::math::round((float)(desiredValue - minValue) / quant)) * quant + minValue; int currentValue = 0; CGObjectInstance * object = nullptr;