mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
Include treasure value in min distance calculation
This commit is contained in:
@ -872,22 +872,12 @@ void TreasurePlacer::createTreasures(ObjectManager& manager)
|
|||||||
|
|
||||||
totalDensity += t->density;
|
totalDensity += t->density;
|
||||||
|
|
||||||
const int DENSITY_CONSTANT = 300;
|
const int DENSITY_CONSTANT = 400;
|
||||||
size_t count = (size * t->density) / DENSITY_CONSTANT;
|
size_t count = (size * t->density) / DENSITY_CONSTANT;
|
||||||
|
|
||||||
//Assure space for lesser treasures, if there are any left
|
|
||||||
const int averageValue = (t->min + t->max) / 2;
|
const int averageValue = (t->min + t->max) / 2;
|
||||||
if (t != (treasureInfo.end() - 1))
|
|
||||||
{
|
|
||||||
if (averageValue > 10000)
|
|
||||||
{
|
|
||||||
//Will surely be guarded => larger piles => less space inbetween
|
|
||||||
vstd::amin(count, size * (10.f / DENSITY_CONSTANT) / (std::sqrt((float)averageValue / 10000)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Integer dvision - round down
|
const float minDistance = std::max<float>(std::sqrt((float)t->min / 10 / totalDensity), 1.0f);
|
||||||
const float minDistance = std::max<float>((125 / totalDensity), 1.0f);
|
|
||||||
|
|
||||||
size_t emergencyLoopFinish = 0;
|
size_t emergencyLoopFinish = 0;
|
||||||
while(treasures.size() < count && emergencyLoopFinish < count)
|
while(treasures.size() < count && emergencyLoopFinish < count)
|
||||||
|
Reference in New Issue
Block a user