From f4de38af80cac5bdf6dc51dbbbbf86451cc2acc3 Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Wed, 14 Jun 2017 16:35:34 +0100 Subject: Remove sign conversion --- src/Chunk.cpp | 2 +- src/MobSpawner.cpp | 3 ++- src/World.cpp | 10 +++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Chunk.cpp b/src/Chunk.cpp index a5818fbeb..b6576486c 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -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) - 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); a_X = Random % a_MaxX; diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp index 98c428bab..2ddf60bbd 100644 --- a/src/MobSpawner.cpp +++ b/src/MobSpawner.cpp @@ -112,7 +112,8 @@ eMonsterType cMobSpawner::ChooseMobType(EMCSBiome a_Biome) { std::set::iterator itr = allowedMobs.begin(); - std::advance(itr, GetRandomProvider().RandInt(allowedMobsSize - 1)); + using DiffType = decltype(itr)::difference_type; + std::advance(itr, GetRandomProvider().RandInt(allowedMobsSize - 1)); return *itr; } diff --git a/src/World.cpp b/src/World.cpp index 0fa719670..9351dd0de 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -1733,7 +1733,7 @@ bool cWorld::GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsBy } else { - BlockMeta += random.RandInt(2, 5); + BlockMeta += random.RandInt(2, 5); BlockMeta = std::min(BlockMeta, static_cast(7)); } 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 { - BlockMeta += random.RandInt(2, 5); + BlockMeta += random.RandInt(2, 5); BlockMeta = std::min(BlockMeta, static_cast(7)); } 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 { - BlockMeta += random.RandInt(2, 5); + BlockMeta += random.RandInt(2, 5); BlockMeta = std::min(BlockMeta, static_cast(7)); } 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 { - BlockMeta += random.RandInt(2, 5); + BlockMeta += random.RandInt(2, 5); BlockMeta = std::min(BlockMeta, static_cast(7)); } 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 { - BlockMeta += random.RandInt(2, 5); + BlockMeta += random.RandInt(2, 5); BlockMeta = std::min(BlockMeta, static_cast(7)); } FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta); -- cgit v1.2.3