1
0

Remove sign conversion

This commit is contained in:
peterbell10 2017-06-14 16:35:34 +01:00 committed by Lukas Pioch
parent 885d80ccdb
commit f4de38af80
3 changed files with 8 additions and 7 deletions

View File

@ -514,7 +514,7 @@ void cChunk::GetThreeRandomNumbers(int & a_X, int & a_Y, int & a_Z, int a_MaxX,
); );
// MTRand gives an inclusive range [0, Max] but this gives the exclusive range [0, Max) // MTRand gives an inclusive range [0, Max] but this gives the exclusive range [0, Max)
int OverallMax = (a_MaxX - 1) * (a_MaxY - 1) * (a_MaxZ - 1); int OverallMax = (a_MaxX * a_MaxY * a_MaxZ) - 1;
int Random = m_World->GetTickRandomNumber(OverallMax); int Random = m_World->GetTickRandomNumber(OverallMax);
a_X = Random % a_MaxX; a_X = Random % a_MaxX;

View File

@ -112,7 +112,8 @@ eMonsterType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
{ {
std::set<eMonsterType>::iterator itr = allowedMobs.begin(); std::set<eMonsterType>::iterator itr = allowedMobs.begin();
std::advance(itr, GetRandomProvider().RandInt<size_t>(allowedMobsSize - 1)); using DiffType = decltype(itr)::difference_type;
std::advance(itr, GetRandomProvider().RandInt<DiffType>(allowedMobsSize - 1));
return *itr; return *itr;
} }

View File

@ -1733,7 +1733,7 @@ bool cWorld::GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsBy
} }
else else
{ {
BlockMeta += random.RandInt(2, 5); BlockMeta += random.RandInt<NIBBLETYPE>(2, 5);
BlockMeta = std::min(BlockMeta, static_cast<NIBBLETYPE>(7)); BlockMeta = std::min(BlockMeta, static_cast<NIBBLETYPE>(7));
} }
FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta); FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta);
@ -1768,7 +1768,7 @@ bool cWorld::GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsBy
} }
else else
{ {
BlockMeta += random.RandInt(2, 5); BlockMeta += random.RandInt<NIBBLETYPE>(2, 5);
BlockMeta = std::min(BlockMeta, static_cast<NIBBLETYPE>(7)); BlockMeta = std::min(BlockMeta, static_cast<NIBBLETYPE>(7));
} }
FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta); FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta);
@ -1791,7 +1791,7 @@ bool cWorld::GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsBy
} }
else else
{ {
BlockMeta += random.RandInt(2, 5); BlockMeta += random.RandInt<NIBBLETYPE>(2, 5);
BlockMeta = std::min(BlockMeta, static_cast<NIBBLETYPE>(7)); BlockMeta = std::min(BlockMeta, static_cast<NIBBLETYPE>(7));
} }
FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta); FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta);
@ -1823,7 +1823,7 @@ bool cWorld::GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsBy
} }
else else
{ {
BlockMeta += random.RandInt(2, 5); BlockMeta += random.RandInt<NIBBLETYPE>(2, 5);
BlockMeta = std::min(BlockMeta, static_cast<NIBBLETYPE>(7)); BlockMeta = std::min(BlockMeta, static_cast<NIBBLETYPE>(7));
} }
FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta); FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta);
@ -1846,7 +1846,7 @@ bool cWorld::GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsBy
} }
else else
{ {
BlockMeta += random.RandInt(2, 5); BlockMeta += random.RandInt<NIBBLETYPE>(2, 5);
BlockMeta = std::min(BlockMeta, static_cast<NIBBLETYPE>(7)); BlockMeta = std::min(BlockMeta, static_cast<NIBBLETYPE>(7));
} }
FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta); FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta);