diff options
-rw-r--r-- | src/Bindings/DeprecatedBindings.cpp | 2 | ||||
-rw-r--r-- | src/Blocks/BlockHandler.cpp | 2 | ||||
-rw-r--r-- | src/Entities/ItemFrame.cpp | 13 | ||||
-rw-r--r-- | src/Generating/FinishGen.cpp | 2 | ||||
-rw-r--r-- | src/Generating/IntGen.h | 3 | ||||
-rw-r--r-- | src/Generating/ProtIntGen.h | 2 | ||||
-rw-r--r-- | src/Generating/Trees.cpp | 6 | ||||
-rw-r--r-- | src/ItemGrid.cpp | 2 | ||||
-rw-r--r-- | src/Items/ItemSign.h | 2 |
9 files changed, 22 insertions, 12 deletions
diff --git a/src/Bindings/DeprecatedBindings.cpp b/src/Bindings/DeprecatedBindings.cpp index d2400e7d1..ea7d9bf2a 100644 --- a/src/Bindings/DeprecatedBindings.cpp +++ b/src/Bindings/DeprecatedBindings.cpp @@ -455,7 +455,7 @@ static int tolua_cNoteEntity_SetPitch(lua_State * tolua_S) tolua_error(LuaState, "invalid 'self' in function 'SetPitch'", nullptr); } - Self->SetNote(Note % 25); + Self->SetNote(static_cast<unsigned char>(Note % 25)); LOGWARNING("Warning: 'cNoteEntity:SetPitch' function is deprecated. Please use 'cNoteEntity:SetNote' instead."); LuaState.LogStackTrace(0); return 1; diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 819289e14..2ce7904ab 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -618,7 +618,7 @@ unsigned char cBlockHandler::ToolFortuneLevel(const cItem * a_Tool) char cBlockHandler::FortuneDiscreteRandom(char a_MinDrop, char a_DefaultMax, unsigned char a_BonusMax, char a_DropCap) { // First sample the discrete random distribution. - char DropNum = GetRandomProvider().RandInt<char>(a_MinDrop, a_DefaultMax + a_BonusMax); + char DropNum = GetRandomProvider().RandInt<char>(a_MinDrop, static_cast<char>(a_DefaultMax + a_BonusMax)); // Then clamp to within range (clamp instead of min incase of overflow): return std::clamp<char>(DropNum, a_MinDrop, a_DropCap); diff --git a/src/Entities/ItemFrame.cpp b/src/Entities/ItemFrame.cpp index ef2939e06..eeab06737 100644 --- a/src/Entities/ItemFrame.cpp +++ b/src/Entities/ItemFrame.cpp @@ -4,6 +4,7 @@ #include "ItemFrame.h" #include "Player.h" #include "../ClientHandle.h" +#include "Chunk.h" @@ -26,7 +27,7 @@ void cItemFrame::OnRightClicked(cPlayer & a_Player) if (!m_Item.IsEmpty()) { - // Item not empty, rotate, clipping values to zero to three inclusive + // Item not empty, rotate, clipping values to zero to seven inclusive m_ItemRotation++; if (m_ItemRotation >= 8) { @@ -46,6 +47,7 @@ void cItemFrame::OnRightClicked(cPlayer & a_Player) } GetWorld()->BroadcastEntityMetadata(*this); // Update clients + GetParentChunk()->MarkDirty(); // Mark chunk dirty to save rotation or item } @@ -97,4 +99,13 @@ void cItemFrame::SpawnOn(cClientHandle & a_ClientHandle) Super::SpawnOn(a_ClientHandle); a_ClientHandle.SendSpawnEntity(*this); a_ClientHandle.SendEntityMetadata(*this); + + if (m_Item.m_ItemType == E_ITEM_MAP) + { + cMap * Map = GetWorld()->GetMapManager().GetMapData(static_cast<unsigned>(m_Item.m_ItemDamage)); + if (Map != nullptr) + { + a_ClientHandle.SendMapData(*Map, 0, 0); + } + } } diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index a6da93976..984957e60 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -613,7 +613,7 @@ void cFinishGenTallGrass::GenFinish(cChunkDesc & a_ChunkDesc) } else { - NIBBLETYPE meta = (m_Noise.IntNoise2DInt(xx * 50, zz * 50) / 7 % 2) + 1; + NIBBLETYPE meta = static_cast<NIBBLETYPE>((m_Noise.IntNoise2DInt(xx * 50, zz * 50) / 7 % 2) + 1); a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, meta); a_ChunkDesc.SetHeight(x, z, static_cast<HEIGHTTYPE>(y)); } diff --git a/src/Generating/IntGen.h b/src/Generating/IntGen.h index 4ef8c3452..b56567f9f 100644 --- a/src/Generating/IntGen.h +++ b/src/Generating/IntGen.h @@ -1,4 +1,3 @@ - // IntGen.h // Declares the cIntGen class and descendants for generating and filtering various 2D arrays of ints @@ -494,7 +493,7 @@ public: if (IsBiomeOcean(above) || IsBiomeOcean(below) || IsBiomeOcean(left) || IsBiomeOcean(right)) { // First convert the value to a regular biome (drop the M flag), then modulo by our biome count: - val = ToBeach[(val % 128) % ARRAYCOUNT(ToBeach)]; + val = ToBeach[static_cast<size_t>((val % 128)) % ARRAYCOUNT(ToBeach)]; } } a_Values[x + z * SizeX] = val; diff --git a/src/Generating/ProtIntGen.h b/src/Generating/ProtIntGen.h index 87e13c6cc..290998075 100644 --- a/src/Generating/ProtIntGen.h +++ b/src/Generating/ProtIntGen.h @@ -767,7 +767,7 @@ public: if (IsBiomeOcean(above) || IsBiomeOcean(below) || IsBiomeOcean(left) || IsBiomeOcean(right)) { // First convert the value to a regular biome (drop the M flag), then modulo by our biome count: - val = ToBeach[(val % 128) % ARRAYCOUNT(ToBeach)]; + val = ToBeach[static_cast<size_t>(val % 128) % ARRAYCOUNT(ToBeach)]; } } a_Values[x + z * a_SizeX] = val; diff --git a/src/Generating/Trees.cpp b/src/Generating/Trees.cpp index 28f0da6ce..53017ce06 100644 --- a/src/Generating/Trees.cpp +++ b/src/Generating/Trees.cpp @@ -672,7 +672,7 @@ NIBBLETYPE GetLogMetaFromDirection(NIBBLETYPE a_BlockMeta, Vector3d a_Direction) void GetBirchTreeImage(Vector3i a_BlockPos, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks) { - HEIGHTTYPE Height = 5 + (a_Noise.IntNoise3DInt(a_BlockPos.addedX(64 * a_Seq)) % 3); + HEIGHTTYPE Height = 5 + static_cast<HEIGHTTYPE>(a_Noise.IntNoise3DInt(a_BlockPos.addedX(64 * a_Seq)) % 3); // Prealloc, so that we don't realloc too often later: a_LogBlocks.reserve(static_cast<size_t>(Height)); @@ -839,7 +839,7 @@ void GetDarkoakTreeImage(Vector3i a_BlockPos, cNoise & a_Noise, int a_Seq, sSetB void GetTallBirchTreeImage(Vector3i a_BlockPos, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks) { - HEIGHTTYPE Height = 9 + (a_Noise.IntNoise3DInt(a_BlockPos.addedX(64 * a_Seq)) % 3); + HEIGHTTYPE Height = 9 + static_cast<HEIGHTTYPE>(a_Noise.IntNoise3DInt(a_BlockPos.addedX(64 * a_Seq)) % 3); // Prealloc, so that we don't realloc too often later: a_LogBlocks.reserve(static_cast<size_t>(Height)); @@ -1078,7 +1078,7 @@ void GetLargeSpruceTreeImage(Vector3i a_BlockPos, cNoise & a_Noise, int a_Seq, s for (int i = 0; i < LeavesRingCount; i++) { - unsigned int Val = (a_Noise.IntNoise3DInt(a_BlockPos.addedXZ(32 * a_Seq, 32 * i)) / 23) % 8; + unsigned int Val = static_cast<unsigned int>(a_Noise.IntNoise3DInt(a_BlockPos.addedXZ(32 * a_Seq, 32 * i)) / 23) % 8; if ((Val < 4) && RingRadius < 3) { RingRadius++; diff --git a/src/ItemGrid.cpp b/src/ItemGrid.cpp index 790f078fc..a4cf41a14 100644 --- a/src/ItemGrid.cpp +++ b/src/ItemGrid.cpp @@ -770,7 +770,7 @@ void cItemGrid::GenerateRandomLootWithBooks(const cLootProbab * a_LootProbabs, s // Choose the enchantments cWeightedEnchantments Enchantments; - cEnchantments::AddItemEnchantmentWeights(Enchantments, E_ITEM_BOOK, 24 + Noise.IntNoise2DInt(a_Seed, TotalProbab) % 7); + cEnchantments::AddItemEnchantmentWeights(Enchantments, E_ITEM_BOOK, static_cast<unsigned>(24 + Noise.IntNoise2DInt(a_Seed, TotalProbab) % 7)); int NumEnchantments = Noise.IntNoise3DInt(TotalProbab, Rnd, a_Seed) % 5; // The number of enchantments this book wil get. for (int j = 0; j <= NumEnchantments; j++) diff --git a/src/Items/ItemSign.h b/src/Items/ItemSign.h index fc5174e0b..02913b58f 100644 --- a/src/Items/ItemSign.h +++ b/src/Items/ItemSign.h @@ -77,7 +77,7 @@ private: a_Rotation = (a_Rotation / 360) * 16; - return static_cast<char>(a_Rotation) % 16; + return static_cast<NIBBLETYPE>(a_Rotation) % 16; } } ; |