Fixed grass spread, closes #1743
- Removed the salt parameter in cFastRandom functions, it wasn't doing what we thought it was following the move to C++11
This commit is contained in:
parent
57d2a09c8c
commit
e94886c140
@ -69,9 +69,9 @@ public:
|
|||||||
cFastRandom rand;
|
cFastRandom rand;
|
||||||
for (int i = 0; i < 2; i++) // Pick two blocks to grow to
|
for (int i = 0; i < 2; i++) // Pick two blocks to grow to
|
||||||
{
|
{
|
||||||
int OfsX = rand.NextInt(3, a_RelX) - 1; // [-1 .. 1]
|
int OfsX = rand.NextInt(3) - 1; // [-1 .. 1]
|
||||||
int OfsY = rand.NextInt(5, a_RelY) - 3; // [-3 .. 1]
|
int OfsY = rand.NextInt(5) - 3; // [-3 .. 1]
|
||||||
int OfsZ = rand.NextInt(3, a_RelZ) - 1; // [-1 .. 1]
|
int OfsZ = rand.NextInt(3) - 1; // [-1 .. 1]
|
||||||
|
|
||||||
BLOCKTYPE DestBlock;
|
BLOCKTYPE DestBlock;
|
||||||
NIBBLETYPE DestMeta;
|
NIBBLETYPE DestMeta;
|
||||||
|
@ -105,18 +105,6 @@ int cFastRandom::NextInt(int a_Range)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int cFastRandom::NextInt(int a_Range, int a_Salt)
|
|
||||||
{
|
|
||||||
m_LinearRand.seed(a_Salt);
|
|
||||||
std::uniform_int_distribution<> distribution(0, a_Range - 1);
|
|
||||||
return distribution(m_LinearRand);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float cFastRandom::NextFloat(float a_Range)
|
float cFastRandom::NextFloat(float a_Range)
|
||||||
{
|
{
|
||||||
std::uniform_real_distribution<float> distribution(0, a_Range);
|
std::uniform_real_distribution<float> distribution(0, a_Range);
|
||||||
@ -128,18 +116,6 @@ float cFastRandom::NextFloat(float a_Range)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
float cFastRandom::NextFloat(float a_Range, int a_Salt)
|
|
||||||
{
|
|
||||||
m_LinearRand.seed(a_Salt);
|
|
||||||
std::uniform_real_distribution<float> distribution(0, a_Range);
|
|
||||||
return distribution(m_LinearRand);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int cFastRandom::GenerateRandomInteger(int a_Begin, int a_End)
|
int cFastRandom::GenerateRandomInteger(int a_Begin, int a_End)
|
||||||
{
|
{
|
||||||
std::uniform_int_distribution<> distribution(a_Begin, a_End);
|
std::uniform_int_distribution<> distribution(a_Begin, a_End);
|
||||||
|
@ -37,15 +37,9 @@ public:
|
|||||||
/** Returns a random int in the range [0 .. a_Range - 1]; a_Range must be less than 1M */
|
/** Returns a random int in the range [0 .. a_Range - 1]; a_Range must be less than 1M */
|
||||||
int NextInt(int a_Range);
|
int NextInt(int a_Range);
|
||||||
|
|
||||||
/** Returns a random int in the range [0 .. a_Range - 1]; a_Range must be less than 1M; a_Salt is additional source of randomness */
|
|
||||||
int NextInt(int a_Range, int a_Salt);
|
|
||||||
|
|
||||||
/** Returns a random float in the range [0 .. a_Range]; a_Range must be less than 1M */
|
/** Returns a random float in the range [0 .. a_Range]; a_Range must be less than 1M */
|
||||||
float NextFloat(float a_Range);
|
float NextFloat(float a_Range);
|
||||||
|
|
||||||
/** Returns a random float in the range [0 .. a_Range]; a_Range must be less than 1M; a_Salt is additional source of randomness */
|
|
||||||
float NextFloat(float a_Range, int a_Salt);
|
|
||||||
|
|
||||||
/** Returns a random float between 0 and 1. */
|
/** Returns a random float between 0 and 1. */
|
||||||
float NextFloat(void) { return NextFloat(1); }
|
float NextFloat(void) { return NextFloat(1); }
|
||||||
|
|
||||||
|
@ -66,10 +66,8 @@ void cMapDecorator::Update(void)
|
|||||||
{
|
{
|
||||||
cFastRandom Random;
|
cFastRandom Random;
|
||||||
|
|
||||||
Int64 WorldAge = m_Player->GetWorld()->GetWorldAge();
|
|
||||||
|
|
||||||
// TODO 2014-02-19 xdot: Refine
|
// TODO 2014-02-19 xdot: Refine
|
||||||
m_Rot = Random.NextInt(16, (int) WorldAge);
|
m_Rot = Random.NextInt(16);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -110,8 +110,7 @@ eMonsterType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
|
|||||||
if (allowedMobsSize > 0)
|
if (allowedMobsSize > 0)
|
||||||
{
|
{
|
||||||
std::set<eMonsterType>::iterator itr = allowedMobs.begin();
|
std::set<eMonsterType>::iterator itr = allowedMobs.begin();
|
||||||
static int Counter = 0;
|
int iRandom = m_Random.NextInt((int)allowedMobsSize);
|
||||||
int iRandom = m_Random.NextInt((int)allowedMobsSize, Counter++);
|
|
||||||
|
|
||||||
for (int i = 0; i < iRandom; i++)
|
for (int i = 0; i < iRandom; i++)
|
||||||
{
|
{
|
||||||
@ -187,7 +186,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
|
|||||||
(BlockBelow == E_BLOCK_GRASS) || (BlockBelow == E_BLOCK_LEAVES) || (BlockBelow == E_BLOCK_NEW_LEAVES)
|
(BlockBelow == E_BLOCK_GRASS) || (BlockBelow == E_BLOCK_LEAVES) || (BlockBelow == E_BLOCK_NEW_LEAVES)
|
||||||
) &&
|
) &&
|
||||||
(a_RelY >= 62) &&
|
(a_RelY >= 62) &&
|
||||||
(Random.NextInt(3, a_Biome) != 0)
|
(Random.NextInt(3) != 0)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,7 +247,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
|
|||||||
(!cBlockInfo::IsTransparent(BlockBelow)) &&
|
(!cBlockInfo::IsTransparent(BlockBelow)) &&
|
||||||
(SkyLight <= 7) &&
|
(SkyLight <= 7) &&
|
||||||
(BlockLight <= 7) &&
|
(BlockLight <= 7) &&
|
||||||
(Random.NextInt(2, a_Biome) == 0)
|
(Random.NextInt(2) == 0)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +271,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
|
|||||||
(TargetBlock == E_BLOCK_AIR) &&
|
(TargetBlock == E_BLOCK_AIR) &&
|
||||||
(BlockAbove == E_BLOCK_AIR) &&
|
(BlockAbove == E_BLOCK_AIR) &&
|
||||||
(!cBlockInfo::IsTransparent(BlockBelow)) &&
|
(!cBlockInfo::IsTransparent(BlockBelow)) &&
|
||||||
(Random.NextInt(20, a_Biome) == 0)
|
(Random.NextInt(20) == 0)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user