1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Quantize treasure values to let objects at upper bound spawn.

This commit is contained in:
DjWarmonger
2014-07-30 10:58:45 +02:00
parent 5814a057c8
commit f9245e67e8

View File

@@ -672,6 +672,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;
int currentValue = 0;
CGObjectInstance * object = nullptr;