1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-23 00:28:08 +02:00

Corrected treasure value rounding.

This commit is contained in:
DjWarmonger
2014-07-30 15:00:44 +02:00
parent e5f3a60c9e
commit e1936b4b0d

View File

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