From 250b8eb652a57dcbdff4af7b6efb9c2554b45798 Mon Sep 17 00:00:00 2001 From: x12xx12x <44411062+12xx12@users.noreply.github.com> Date: Fri, 26 Nov 2021 00:51:47 +0100 Subject: Fixed Compiler Warnings --- src/BlockEntities/BeaconEntity.cpp | 4 +-- src/BlockEntities/HopperEntity.cpp | 2 +- src/BlockInServerPluginInterface.h | 4 +-- src/Blocks/BlockInfested.h | 2 +- src/ClientHandle.cpp | 16 ++++----- src/Color.cpp | 2 +- src/Entities/Pickup.cpp | 8 ++--- src/Entities/Player.cpp | 2 +- src/Generating/BioGen.cpp | 38 +++++++++++----------- src/Generating/FinishGen.cpp | 2 +- src/Generating/PieceModifier.cpp | 21 ++---------- src/Generating/PrefabPiecePool.cpp | 16 --------- src/Generating/Trees.cpp | 2 +- src/Generating/VerticalLimit.cpp | 16 --------- src/Generating/VerticalStrategy.cpp | 15 --------- src/Inventory.cpp | 16 ++++----- src/Inventory.h | 6 ++-- src/ItemGrid.cpp | 28 ++++++++-------- src/ItemGrid.h | 12 +++---- src/LoggerSimple.h | 9 +++++ src/Mobs/Chicken.cpp | 2 +- src/Mobs/Monster.cpp | 6 ++-- src/Mobs/Mooshroom.cpp | 2 +- src/Mobs/Pig.cpp | 2 +- src/Mobs/Sheep.cpp | 2 +- src/OSSupport/IsThread.cpp | 2 +- src/Physics/Explodinator.cpp | 14 ++++---- src/Protocol/Protocol_1_8.cpp | 2 +- .../RedstoneRepeaterHandler.h | 2 +- src/UI/BeaconWindow.cpp | 4 +-- src/UI/SlotArea.cpp | 4 +-- src/UI/Window.cpp | 16 ++++----- src/UI/Window.h | 2 +- src/WorldStorage/NBTChunkSerializer.cpp | 2 +- 34 files changed, 114 insertions(+), 169 deletions(-) diff --git a/src/BlockEntities/BeaconEntity.cpp b/src/BlockEntities/BeaconEntity.cpp index 87d25e57a..bff1b2e18 100644 --- a/src/BlockEntities/BeaconEntity.cpp +++ b/src/BlockEntities/BeaconEntity.cpp @@ -106,7 +106,7 @@ bool cBeaconEntity::SetPrimaryEffect(cEntityEffect::eType a_Effect) // Send window update: if (GetWindow() != nullptr) { - GetWindow()->SetProperty(1, m_PrimaryEffect); + GetWindow()->SetProperty(1, static_cast(m_PrimaryEffect)); } return true; } @@ -128,7 +128,7 @@ bool cBeaconEntity::SetSecondaryEffect(cEntityEffect::eType a_Effect) // Send window update: if (GetWindow() != nullptr) { - GetWindow()->SetProperty(2, m_SecondaryEffect); + GetWindow()->SetProperty(2, static_cast(m_SecondaryEffect)); } return true; } diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp index 1e5c59c94..6c8a72c7e 100644 --- a/src/BlockEntities/HopperEntity.cpp +++ b/src/BlockEntities/HopperEntity.cpp @@ -254,7 +254,7 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk) { m_bFoundPickupsAbove = true; - int PreviousCount = m_Contents.GetSlot(i).m_ItemCount; + char PreviousCount = m_Contents.GetSlot(i).m_ItemCount; Item.m_ItemCount -= m_Contents.ChangeSlotCount(i, Item.m_ItemCount) - PreviousCount; // Set count to however many items were added diff --git a/src/BlockInServerPluginInterface.h b/src/BlockInServerPluginInterface.h index f3ed774f7..1c6eff193 100644 --- a/src/BlockInServerPluginInterface.h +++ b/src/BlockInServerPluginInterface.h @@ -29,12 +29,12 @@ public: virtual bool CallHookPlayerBreakingBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override { - return cPluginManager::Get()->CallHookPlayerBreakingBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockType, a_BlockMeta); + return cPluginManager::Get()->CallHookPlayerBreakingBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, static_cast(a_BlockFace), a_BlockType, a_BlockMeta); } virtual bool CallHookPlayerBrokenBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override { - return cPluginManager::Get()->CallHookPlayerBrokenBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockType, a_BlockMeta); + return cPluginManager::Get()->CallHookPlayerBrokenBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, static_cast(a_BlockFace), a_BlockType, a_BlockMeta); } private: diff --git a/src/Blocks/BlockInfested.h b/src/Blocks/BlockInfested.h index 06c69984b..4fcb5c19e 100644 --- a/src/Blocks/BlockInfested.h +++ b/src/Blocks/BlockInfested.h @@ -24,7 +24,7 @@ private: { // TODO: only display animation if the difficulty allows mob spawns - Add when difficulty is implemented - const auto Position = Vector3f(a_BlockPos.x + 0.5f, a_BlockPos.y, a_BlockPos.z + 0.5f); + const auto Position = Vector3f(a_BlockPos.x + 0.5f, static_cast(a_BlockPos.y), a_BlockPos.z + 0.5f); a_WorldInterface.SpawnMob(Position.x, Position.y, Position.z, mtSilverfish, false); a_WorldInterface.GetBroadcastManager().BroadcastParticleEffect("explode", Position, Vector3f(), 0.1f, 50); } diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index c2135777b..0f5e4d678 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1140,7 +1140,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB } cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager(); - if (m_Player->IsFrozen() || PlgMgr->CallHookPlayerLeftClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, static_cast(a_Status))) + if (m_Player->IsFrozen() || PlgMgr->CallHookPlayerLeftClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, static_cast(a_BlockFace), static_cast(a_Status))) { // A plugin doesn't agree with the action, replace the block on the client and quit: m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, *m_Player); @@ -1371,7 +1371,7 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo cWorld * World = m_Player->GetWorld(); - if (cRoot::Get()->GetPluginManager()->CallHookPlayerBreakingBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, DugBlock, DugMeta)) + if (cRoot::Get()->GetPluginManager()->CallHookPlayerBreakingBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, static_cast(a_BlockFace), DugBlock, DugMeta)) { // A plugin doesn't agree with the breaking. Bail out. Send the block back to the client, so that it knows: m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, *m_Player); @@ -1403,7 +1403,7 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo } World->BroadcastSoundParticleEffect(EffectID::PARTICLE_BLOCK_BREAK, absPos, DugBlock, this); - cRoot::Get()->GetPluginManager()->CallHookPlayerBrokenBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, DugBlock, DugMeta); + cRoot::Get()->GetPluginManager()->CallHookPlayerBrokenBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, static_cast(a_BlockFace), DugBlock, DugMeta); } @@ -1480,7 +1480,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager(); if ( - !PlgMgr->CallHookPlayerRightClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ) && + !PlgMgr->CallHookPlayerRightClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, static_cast(a_BlockFace), a_CursorX, a_CursorY, a_CursorZ) && IsWithinReach && !m_Player->IsFrozen() ) { @@ -1500,12 +1500,12 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e if (BlockUsable && !(m_Player->IsCrouched() && !HeldItem.IsEmpty())) { cChunkInterface ChunkInterface(World->GetChunkMap()); - if (!PlgMgr->CallHookPlayerUsingBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta)) + if (!PlgMgr->CallHookPlayerUsingBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, static_cast(a_BlockFace), a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta)) { // Use a block: if (BlockHandler.OnUse(ChunkInterface, *World, *m_Player, ClickedPosition, a_BlockFace, CursorPosition)) { - PlgMgr->CallHookPlayerUsedBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta); + PlgMgr->CallHookPlayerUsedBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, static_cast(a_BlockFace), a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta); return; // Block use was successful, we're done. } @@ -1533,14 +1533,14 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e ItemHandler.OnPlayerPlace(*m_Player, HeldItem, ClickedPosition, BlockType, BlockMeta, a_BlockFace, CursorPosition); return; } - else if (!PlgMgr->CallHookPlayerUsingItem(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ)) + else if (!PlgMgr->CallHookPlayerUsingItem(*m_Player, a_BlockX, a_BlockY, a_BlockZ, static_cast(a_BlockFace), a_CursorX, a_CursorY, a_CursorZ)) { // All plugins agree with using the item. // Use an item in hand with a target block. cBlockInServerPluginInterface PluginInterface(*World); ItemHandler.OnItemUse(World, m_Player, PluginInterface, HeldItem, ClickedPosition, a_BlockFace); - PlgMgr->CallHookPlayerUsedItem(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ); + PlgMgr->CallHookPlayerUsedItem(*m_Player, a_BlockX, a_BlockY, a_BlockZ, static_cast(a_BlockFace), a_CursorX, a_CursorY, a_CursorZ); return; } } diff --git a/src/Color.cpp b/src/Color.cpp index f2180e2d9..bcaa3eff3 100644 --- a/src/Color.cpp +++ b/src/Color.cpp @@ -54,7 +54,7 @@ void cColor::SetBlue(unsigned char a_Blue) unsigned char cColor::GetRed() const { - return (m_Color & COLOR_RED_BITS) >> COLOR_RED_OFFSET; + return static_cast((m_Color & COLOR_RED_BITS) >> COLOR_RED_OFFSET); } diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp index bbc3313da..f37bb6b98 100644 --- a/src/Entities/Pickup.cpp +++ b/src/Entities/Pickup.cpp @@ -45,7 +45,7 @@ public: cItem & Item = OtherPickup.GetItem(); if ((Distance < 1.2) && Item.IsEqual(m_Pickup->GetItem()) && OtherPickup.CanCombine()) { - short CombineCount = Item.m_ItemCount; + char CombineCount = Item.m_ItemCount; if ((CombineCount + m_Pickup->GetItem().m_ItemCount) > Item.GetMaxStackSize()) { CombineCount = Item.GetMaxStackSize() - m_Pickup->GetItem().m_ItemCount; @@ -56,7 +56,7 @@ public: return false; } - m_Pickup->GetItem().AddCount(static_cast(CombineCount)); + m_Pickup->GetItem().AddCount(CombineCount); Item.m_ItemCount -= CombineCount; if (Item.m_ItemCount <= 0) @@ -265,11 +265,9 @@ bool cPickup::CollectedBy(cEntity & a_Dest) // Pickup cannot be collected because the entity has not enough space return false; } - } else if (a_Dest.IsPlayer()) { - auto & Player = static_cast(a_Dest); // If the player is a spectator, he cannot collect anything @@ -284,7 +282,7 @@ bool cPickup::CollectedBy(cEntity & a_Dest) return false; } - int NumAdded = Player.GetInventory().AddItem(m_Item); + char NumAdded = Player.GetInventory().AddItem(m_Item); if (NumAdded > 0) { // Check achievements diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index b0ab94874..c5c3114d8 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -2344,7 +2344,7 @@ void cPlayer::SendBlocksAround(int a_BlockX, int a_BlockY, int a_BlockZ, int a_R { for (int x = a_BlockX - a_Range + 1; x < a_BlockX + a_Range; x++) { - blks.emplace_back(x, y, z, E_BLOCK_AIR, 0); // Use fake blocktype, it will get set later on. + blks.emplace_back(x, y, z, E_BLOCK_AIR, char(0)); // Use fake blocktype, it will get set later on. } } } // for y diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp index 5e8f5dddc..b71259f08 100644 --- a/src/Generating/BioGen.cpp +++ b/src/Generating/BioGen.cpp @@ -796,7 +796,7 @@ EMCSBiome cBioGenTwoLevel::SelectBiome(int a_BiomeGroup, size_t a_BiomeIdx, int EMCSBiome OuterBiome; } ; - static BiomeLevels bgOcean[] = + static BiomeLevels bgOceanBlocks[] = { { biOcean, biOcean, }, { biOcean, biOcean, }, @@ -810,7 +810,7 @@ EMCSBiome cBioGenTwoLevel::SelectBiome(int a_BiomeGroup, size_t a_BiomeIdx, int { biDeepOcean, biDeepOcean, }, { biMushroomIsland, biMushroomShore, } } ; - static BiomeLevels bgFrozen[] = + static BiomeLevels bgFrozenBlocks[] = { { biIcePlains, biIcePlains, }, { biIceMountains, biIceMountains, }, @@ -823,7 +823,7 @@ EMCSBiome cBioGenTwoLevel::SelectBiome(int a_BiomeGroup, size_t a_BiomeIdx, int { biExtremeHillsPlus, biExtremeHillsEdge, }, { biExtremeHillsPlusM, biExtremeHillsPlusM, }, } ; - static BiomeLevels bgTemperate[] = + static BiomeLevels bgTemperateBlocks[] = { { biBirchForestHills, biBirchForest, }, { biBirchForest, biBirchForest, }, @@ -839,7 +839,7 @@ EMCSBiome cBioGenTwoLevel::SelectBiome(int a_BiomeGroup, size_t a_BiomeIdx, int { biSwampland, biSwampland, }, { biSwamplandM, biSwamplandM, }, } ; - static BiomeLevels bgWarm[] = + static BiomeLevels bgWarmBlocks[] = { { biDesertHills, biDesert, }, { biDesert, biDesert, }, @@ -848,7 +848,7 @@ EMCSBiome cBioGenTwoLevel::SelectBiome(int a_BiomeGroup, size_t a_BiomeIdx, int { biSavanna, biSavanna, }, { biSavannaM, biSavannaM, }, } ; - static BiomeLevels bgMesa[] = + static BiomeLevels bgMesaBlocks[] = { { biMesaPlateau, biMesa, }, { biMesaPlateauF, biMesa, }, @@ -858,7 +858,7 @@ EMCSBiome cBioGenTwoLevel::SelectBiome(int a_BiomeGroup, size_t a_BiomeIdx, int { biSavanna, biSavanna, }, { biSavannaPlateau, biSavanna, }, } ; - static BiomeLevels bgConifers[] = + static BiomeLevels bgConifersBlocks[] = { { biTaiga, biTaiga, }, { biTaigaM, biTaigaM, }, @@ -866,7 +866,7 @@ EMCSBiome cBioGenTwoLevel::SelectBiome(int a_BiomeGroup, size_t a_BiomeIdx, int { biMegaSpruceTaiga, biMegaSpruceTaiga, }, { biMegaSpruceTaigaHills, biMegaSpruceTaiga, } } ; - static BiomeLevels bgDenseTrees[] = + static BiomeLevels bgDenseTreesBlocks[] = { { biJungleHills, biJungle, }, { biJungle, biJungleEdge, }, @@ -878,18 +878,18 @@ EMCSBiome cBioGenTwoLevel::SelectBiome(int a_BiomeGroup, size_t a_BiomeIdx, int size_t Count; } BiomeGroups[] = { - { bgOcean, ARRAYCOUNT(bgOcean), }, - { bgOcean, ARRAYCOUNT(bgOcean), }, - { bgFrozen, ARRAYCOUNT(bgFrozen), }, - { bgFrozen, ARRAYCOUNT(bgFrozen), }, - { bgTemperate, ARRAYCOUNT(bgTemperate), }, - { bgTemperate, ARRAYCOUNT(bgTemperate), }, - { bgConifers, ARRAYCOUNT(bgConifers), }, - { bgConifers, ARRAYCOUNT(bgConifers), }, - { bgWarm, ARRAYCOUNT(bgWarm), }, - { bgWarm, ARRAYCOUNT(bgWarm), }, - { bgMesa, ARRAYCOUNT(bgMesa), }, - { bgDenseTrees, ARRAYCOUNT(bgDenseTrees), }, + { bgOceanBlocks, ARRAYCOUNT(bgOceanBlocks), }, + { bgOceanBlocks, ARRAYCOUNT(bgOceanBlocks), }, + { bgFrozenBlocks, ARRAYCOUNT(bgFrozenBlocks), }, + { bgFrozenBlocks, ARRAYCOUNT(bgFrozenBlocks), }, + { bgTemperateBlocks, ARRAYCOUNT(bgTemperateBlocks), }, + { bgTemperateBlocks, ARRAYCOUNT(bgTemperateBlocks), }, + { bgConifersBlocks, ARRAYCOUNT(bgConifersBlocks), }, + { bgConifersBlocks, ARRAYCOUNT(bgConifersBlocks), }, + { bgWarmBlocks, ARRAYCOUNT(bgWarmBlocks), }, + { bgWarmBlocks, ARRAYCOUNT(bgWarmBlocks), }, + { bgMesaBlocks, ARRAYCOUNT(bgMesaBlocks), }, + { bgDenseTreesBlocks, ARRAYCOUNT(bgDenseTreesBlocks), }, } ; size_t Group = static_cast(a_BiomeGroup) % ARRAYCOUNT(BiomeGroups); size_t Index = a_BiomeIdx % BiomeGroups[Group].Count; diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 984957e60..34ca30b26 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -1822,7 +1822,7 @@ cFinishGenOres::OreInfos cFinishGenOres::OreInfosFromString(const AString & a_Or ); continue; } - auto oreType = BlockStringToType(parts[0]); + auto oreType = static_cast(BlockStringToType(parts[0])); if (oreType < 0) { LOGWARNING("Cannot parse ore information from string, invalid OreType: \"%s\".", parts[0].c_str()); diff --git a/src/Generating/PieceModifier.cpp b/src/Generating/PieceModifier.cpp index 54d6a2c21..922e68e40 100644 --- a/src/Generating/PieceModifier.cpp +++ b/src/Generating/PieceModifier.cpp @@ -16,21 +16,6 @@ static const int SEED_OFFSET = 135 * 13; - - -// Emit a warning if the first param is true -#define CONDWARNING(ShouldLog, Fmt, ...) \ - do { \ - if (ShouldLog) \ - { \ - LOGWARNING(Fmt, __VA_ARGS__); \ - } \ - } while (false) - - - - - //////////////////////////////////////////////////////////////////////////////// /** A modifier which is pseudo-randomly replacing blocks to other types and metas. */ class cPieceModifierRandomizeBlocks: @@ -252,7 +237,7 @@ public: { if (m_BlocksToReplace.count(BlockTypes[i])) { - float BlockRnd = PieceNoise.IntNoise2DInRange(a_PieceRot, static_cast(i), 0, m_AllWeights); + float BlockRnd = PieceNoise.IntNoise2DInRange(a_PieceRot, static_cast(i), 0.0F, static_cast(m_AllWeights)); int weightDelta = 0; for (auto & blockToRnd : m_BlocksToRandomize) @@ -265,7 +250,7 @@ public: // Per block meta params if (blockToRnd.m_MinMeta < blockToRnd.m_MaxMeta) { - int BlockMetaRnd = std::clamp(static_cast(PieceNoise.IntNoise2DInRange(a_PieceRot*2, static_cast(i), blockToRnd.m_MinNoiseMeta, blockToRnd.m_MaxNoiseMeta)), blockToRnd.m_MinMeta, blockToRnd.m_MaxMeta); + char BlockMetaRnd = static_cast(std::clamp(static_cast(PieceNoise.IntNoise2DInRange(a_PieceRot*2, static_cast(i), static_cast(blockToRnd.m_MinNoiseMeta), static_cast(blockToRnd.m_MaxNoiseMeta))), blockToRnd.m_MinMeta, blockToRnd.m_MaxMeta)); BlockMetas[i] = static_cast(BlockMetaRnd); } else if ((blockToRnd.m_MaxMeta > -1) && (blockToRnd.m_MaxMeta == blockToRnd.m_MinMeta)) @@ -280,7 +265,7 @@ public: // All blocks meta params if (m_MaxMeta > m_MinMeta) { - int BlockMetaRnd = std::clamp(static_cast(PieceNoise.IntNoise2DInRange(a_PieceRot*2, static_cast(i), m_MinNoiseMeta, m_MaxNoiseMeta)), m_MinMeta, m_MaxMeta); + char BlockMetaRnd = static_cast(std::clamp(static_cast(PieceNoise.IntNoise2DInRange(a_PieceRot * 2, static_cast(i), static_cast(m_MinNoiseMeta), static_cast(m_MaxNoiseMeta))), m_MinMeta, m_MaxMeta)); BlockMetas[i] = static_cast(BlockMetaRnd); } else if ((m_MaxMeta > -1) && (m_MaxMeta == m_MinMeta)) diff --git a/src/Generating/PrefabPiecePool.cpp b/src/Generating/PrefabPiecePool.cpp index 67d464d13..4deee38ef 100644 --- a/src/Generating/PrefabPiecePool.cpp +++ b/src/Generating/PrefabPiecePool.cpp @@ -11,22 +11,6 @@ #include "../StringCompression.h" - - - -// Conditionally log a warning -#define CONDWARNING(ShouldLog, ...) \ - do { \ - if (ShouldLog) \ - { \ - LOGWARNING(__VA_ARGS__); \ - } \ - } while (false) - - - - - /** Returns the map of string => eMergeStrategy used when translating cubeset file merge strategies. */ static std::map & GetMergeStrategyMap(void) { diff --git a/src/Generating/Trees.cpp b/src/Generating/Trees.cpp index 53017ce06..4b3d2c24e 100644 --- a/src/Generating/Trees.cpp +++ b/src/Generating/Trees.cpp @@ -949,7 +949,7 @@ void GetSmallSpruceTreeImage(Vector3i a_BlockPos, cNoise & a_Noise, int a_Seq, s { a_LogBlocks.emplace_back(a_BlockPos.addedY(i), E_BLOCK_LOG, E_META_LOG_CONIFER); } - Height += a_BlockPos.y; + Height += static_cast(a_BlockPos.y); // Optional size-1 bottom leaves layer: if ((MyRandom & 1) == 0) diff --git a/src/Generating/VerticalLimit.cpp b/src/Generating/VerticalLimit.cpp index b3e8ea35d..8ae8c4d9b 100644 --- a/src/Generating/VerticalLimit.cpp +++ b/src/Generating/VerticalLimit.cpp @@ -5,22 +5,6 @@ #include "VerticalLimit.h" - - - -// Emit a warning if the first param is true -#define CONDWARNING(ShouldLog, Fmt, ...) \ - do { \ - if (ShouldLog) \ - { \ - LOGWARNING(Fmt, __VA_ARGS__); \ - } \ - } while (false) - - - - - //////////////////////////////////////////////////////////////////////////////// // Globals: diff --git a/src/Generating/VerticalStrategy.cpp b/src/Generating/VerticalStrategy.cpp index 9fd11865b..3b0307167 100644 --- a/src/Generating/VerticalStrategy.cpp +++ b/src/Generating/VerticalStrategy.cpp @@ -16,21 +16,6 @@ static const int SEED_OFFSET = 135; - - -// Emit a warning if the first param is true -#define CONDWARNING(ShouldLog, Fmt, ...) \ - do { \ - if (ShouldLog) \ - { \ - LOGWARNING(Fmt, __VA_ARGS__); \ - } \ - } while (false) - - - - - //////////////////////////////////////////////////////////////////////////////// // Globals: diff --git a/src/Inventory.cpp b/src/Inventory.cpp index 2fdd1c25f..914122cee 100644 --- a/src/Inventory.cpp +++ b/src/Inventory.cpp @@ -78,7 +78,7 @@ int cInventory::HowManyCanFit(const cItem & a_ItemStack, int a_BeginSlotNum, int } char NumLeft = a_ItemStack.m_ItemCount; - int MaxStack = a_ItemStack.GetMaxStackSize(); + char MaxStack = a_ItemStack.GetMaxStackSize(); for (int i = a_BeginSlotNum; i <= a_EndSlotNum; i++) { const cItem & Slot = GetSlot(i); @@ -103,12 +103,12 @@ int cInventory::HowManyCanFit(const cItem & a_ItemStack, int a_BeginSlotNum, int -int cInventory::AddItem(const cItem & a_Item, bool a_AllowNewStacks) +char cInventory::AddItem(const cItem & a_Item, bool a_AllowNewStacks) { m_Owner.AddKnownItem(a_Item); cItem ToAdd(a_Item); - int res = 0; + char res = 0; // When the item is a armor, try to set it directly to the armor slot. if (ItemCategory::IsArmor(a_Item.m_ItemType)) @@ -162,12 +162,12 @@ int cInventory::AddItem(const cItem & a_Item, bool a_AllowNewStacks) -int cInventory::AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks) +char cInventory::AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks) { - int TotalAdded = 0; + char TotalAdded = 0; for (cItems::iterator itr = a_ItemStackList.begin(); itr != a_ItemStackList.end();) { - int NumAdded = AddItem(*itr, a_AllowNewStacks); + char NumAdded = AddItem(*itr, a_AllowNewStacks); if (itr->m_ItemCount == NumAdded) { itr = a_ItemStackList.erase(itr); @@ -188,7 +188,7 @@ int cInventory::AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks) int cInventory::RemoveItem(const cItem & a_ItemStack) { - int RemovedItems = m_ShieldSlots.RemoveItem(a_ItemStack); + char RemovedItems = m_ShieldSlots.RemoveItem(a_ItemStack); if (RemovedItems < a_ItemStack.m_ItemCount) { @@ -495,7 +495,7 @@ bool cInventory::DamageEquippedItem(short a_Amount) -int cInventory::ChangeSlotCount(int a_SlotNum, int a_AddToCount) +char cInventory::ChangeSlotCount(int a_SlotNum, char a_AddToCount) { int GridSlotNum = 0; cItemGrid * Grid = GetGridForSlotNum(a_SlotNum, GridSlotNum); diff --git a/src/Inventory.h b/src/Inventory.h index 7221ded00..c54da5975 100644 --- a/src/Inventory.h +++ b/src/Inventory.h @@ -74,7 +74,7 @@ public: Fills existing stacks first and fills the hotbar before the main inventory. Returns the number of items that fit. */ - int AddItem(const cItem & a_ItemStack, bool a_AllowNewStacks = true); + char AddItem(const cItem & a_ItemStack, bool a_AllowNewStacks = true); /** Same as AddItem, but works on an entire list of item stacks. The a_ItemStackList is modified to reflect the leftover items. @@ -82,7 +82,7 @@ public: if a_AllowNewStacks is set to true, empty slots can be used for the rest. Returns the total number of items that fit. */ - int AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks); + char AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks); /** Removes the specified item from the inventory, as many as possible, up to a_ItemStack.m_ItemCount. Returns the number of items that were removed. */ @@ -165,7 +165,7 @@ public: If the slot is empty, ignores the call. Returns the new count, or -1 if the slot number is invalid. */ - int ChangeSlotCount(int a_SlotNum, int a_AddToCount); + char ChangeSlotCount(int a_SlotNum, char a_AddToCount); /** Adds the specified damage to the specified item; deletes the item and returns true if the item broke. */ bool DamageItem(int a_SlotNum, short a_Amount); diff --git a/src/ItemGrid.cpp b/src/ItemGrid.cpp index 4ffd51b97..33e50d1d0 100644 --- a/src/ItemGrid.cpp +++ b/src/ItemGrid.cpp @@ -280,7 +280,7 @@ int cItemGrid::HowManyCanFit(const cItem & a_ItemStack, bool a_AllowNewStacks) -int cItemGrid::AddItemToSlot(const cItem & a_ItemStack, int a_Slot, int a_Num, int a_MaxStack) +char cItemGrid::AddItemToSlot(const cItem & a_ItemStack, int a_Slot, int a_Num, int a_MaxStack) { if (!IsValidSlotNum(a_Slot)) { @@ -290,7 +290,7 @@ int cItemGrid::AddItemToSlot(const cItem & a_ItemStack, int a_Slot, int a_Num, i return 0; } - int PrevCount = 0; + char PrevCount = 0; if (m_Slots[a_Slot].IsEmpty()) { m_Slots[a_Slot] = a_ItemStack; @@ -301,7 +301,7 @@ int cItemGrid::AddItemToSlot(const cItem & a_ItemStack, int a_Slot, int a_Num, i PrevCount = m_Slots[a_Slot].m_ItemCount; } m_Slots[a_Slot].m_ItemCount = static_cast(std::min(a_MaxStack, PrevCount + a_Num)); - int toReturn = m_Slots[a_Slot].m_ItemCount - PrevCount; + char toReturn = m_Slots[a_Slot].m_ItemCount - PrevCount; TriggerListeners(a_Slot); return toReturn; } @@ -310,10 +310,10 @@ int cItemGrid::AddItemToSlot(const cItem & a_ItemStack, int a_Slot, int a_Num, i -int cItemGrid::AddItem(cItem & a_ItemStack, bool a_AllowNewStacks, int a_PrioritySlot) +char cItemGrid::AddItem(cItem & a_ItemStack, bool a_AllowNewStacks, int a_PrioritySlot) { - int NumLeft = a_ItemStack.m_ItemCount; - int MaxStack = a_ItemStack.GetMaxStackSize(); + char NumLeft = a_ItemStack.m_ItemCount; + char MaxStack = a_ItemStack.GetMaxStackSize(); if ((a_PrioritySlot != -1) && !IsValidSlotNum(a_PrioritySlot)) { @@ -378,12 +378,12 @@ int cItemGrid::AddItem(cItem & a_ItemStack, bool a_AllowNewStacks, int a_Priorit -int cItemGrid::AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks, int a_PrioritySlot) +char cItemGrid::AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks, int a_PrioritySlot) { - int TotalAdded = 0; + char TotalAdded = 0; for (cItems::iterator itr = a_ItemStackList.begin(); itr != a_ItemStackList.end();) { - int NumAdded = AddItem(*itr, a_AllowNewStacks, a_PrioritySlot); + char NumAdded = AddItem(*itr, a_AllowNewStacks, a_PrioritySlot); if (itr->m_ItemCount == NumAdded) { itr = a_ItemStackList.erase(itr); @@ -402,9 +402,9 @@ int cItemGrid::AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks, int a_P -int cItemGrid::RemoveItem(const cItem & a_ItemStack) +char cItemGrid::RemoveItem(const cItem & a_ItemStack) { - int NumLeft = a_ItemStack.m_ItemCount; + char NumLeft = a_ItemStack.m_ItemCount; if (!m_Slots.IsStorageAllocated()) { @@ -420,7 +420,7 @@ int cItemGrid::RemoveItem(const cItem & a_ItemStack) if (m_Slots[i].IsEqual(a_ItemStack)) { - int NumToRemove = std::min(NumLeft, static_cast(m_Slots[i].m_ItemCount)); + char NumToRemove = std::min(NumLeft, m_Slots[i].m_ItemCount); NumLeft -= NumToRemove; m_Slots[i].m_ItemCount -= NumToRemove; @@ -465,7 +465,7 @@ cItem * cItemGrid::FindItem(const cItem & a_RecipeItem) -int cItemGrid::ChangeSlotCount(int a_SlotNum, int a_AddToCount) +char cItemGrid::ChangeSlotCount(int a_SlotNum, char a_AddToCount) { if (!IsValidSlotNum(a_SlotNum)) { @@ -504,7 +504,7 @@ int cItemGrid::ChangeSlotCount(int a_SlotNum, int a_AddToCount) -int cItemGrid::ChangeSlotCount(int a_X, int a_Y, int a_AddToCount) +char cItemGrid::ChangeSlotCount(int a_X, int a_Y, char a_AddToCount) { return ChangeSlotCount(GetSlotNum(a_X, a_Y), a_AddToCount); } diff --git a/src/ItemGrid.h b/src/ItemGrid.h index 52cfbc84a..24acb3c9a 100644 --- a/src/ItemGrid.h +++ b/src/ItemGrid.h @@ -86,7 +86,7 @@ public: If a_PrioritySlot is set to -1, regular order applies. Returns the number of items that fit. */ - int AddItem(cItem & a_ItemStack, bool a_AllowNewStacks = true, int a_PrioritySlot = -1); + char AddItem(cItem & a_ItemStack, bool a_AllowNewStacks = true, int a_PrioritySlot = -1); /** Same as AddItem, but works on an entire list of item stacks. The a_ItemStackList is modified to reflect the leftover items. @@ -96,11 +96,11 @@ public: If a_PrioritySlot is set to -1, regular order applies. Returns the total number of items that fit. */ - int AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks = true, int a_PrioritySlot = -1); + char AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks = true, int a_PrioritySlot = -1); /** Removes the specified item from the grid, as many as possible, up to a_ItemStack.m_ItemCount. Returns the number of items that were removed. */ - int RemoveItem(const cItem & a_ItemStack); + char RemoveItem(const cItem & a_ItemStack); /** Finds an item based on ItemType and ItemDamage (<- defines the itemType, too) */ cItem * FindItem(const cItem & a_RecipeItem); @@ -109,13 +109,13 @@ public: If the slot is empty, ignores the call. Returns the new count. */ - int ChangeSlotCount(int a_SlotNum, int a_AddToCount); + char ChangeSlotCount(int a_SlotNum, char a_AddToCount); /** Adds (or subtracts, if a_AddToCount is negative) to the count of items in the specified slot. If the slot is empty, ignores the call. Returns the new count. */ - int ChangeSlotCount(int a_X, int a_Y, int a_AddToCount); + char ChangeSlotCount(int a_X, int a_Y, char a_AddToCount); /** Removes one item from the stack in the specified slot, and returns it. If the slot was empty, returns an empty item @@ -198,6 +198,6 @@ protected: /** Adds up to a_Num items out of a_ItemStack, as many as can fit, in specified slot Returns the number of items that did fit. */ - int AddItemToSlot(const cItem & a_ItemStack, int a_Slot, int a_Num, int a_MaxStack); + char AddItemToSlot(const cItem & a_ItemStack, int a_Slot, int a_Num, int a_MaxStack); } ; // tolua_end diff --git a/src/LoggerSimple.h b/src/LoggerSimple.h index 7c984d2ca..37ed36bc6 100644 --- a/src/LoggerSimple.h +++ b/src/LoggerSimple.h @@ -94,3 +94,12 @@ void LOGERROR(std::string_view a_Format, const Args & ... args) #endif // !NDEBUG #define FLOGWARN FLOGWARNING + +// Conditionally log a warning +#define CONDWARNING(ShouldLog, ...) \ + do { \ + if (ShouldLog) \ + { \ + LOGWARNING(__VA_ARGS__); \ + } \ + } while (false) diff --git a/src/Mobs/Chicken.cpp b/src/Mobs/Chicken.cpp index 1a6d62fce..bb0a4efbf 100644 --- a/src/Mobs/Chicken.cpp +++ b/src/Mobs/Chicken.cpp @@ -40,7 +40,7 @@ void cChicken::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { cItems Drops; m_EggDropTimer = 0; - Drops.emplace_back(E_ITEM_EGG, 1); + Drops.emplace_back(E_ITEM_EGG, char(1)); m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); } else diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 3193f97ae..0ebf30554 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -1510,8 +1510,8 @@ void cMonster::RightClickFeed(cPlayer & a_Player) void cMonster::AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth) { - auto Count = GetRandomProvider().RandInt(a_Min, a_Max); - auto MaxStackSize = static_cast(cItem(a_Item).GetMaxStackSize()); + auto Count = GetRandomProvider().RandInt(a_Min, a_Max); + char MaxStackSize = ItemHandler(a_Item)->GetMaxStackSize(); while (Count > MaxStackSize) { a_Drops.emplace_back(a_Item, MaxStackSize, a_ItemHealth); @@ -1531,7 +1531,7 @@ void cMonster::AddRandomUncommonDropItem(cItems & a_Drops, float a_Chance, short { if (GetRandomProvider().RandBool(a_Chance / 100.0)) { - a_Drops.emplace_back(a_Item, 1, a_ItemHealth); + a_Drops.emplace_back(a_Item, char(1), a_ItemHealth); } } diff --git a/src/Mobs/Mooshroom.cpp b/src/Mobs/Mooshroom.cpp index 1e0d13c9b..3e4cb7154 100644 --- a/src/Mobs/Mooshroom.cpp +++ b/src/Mobs/Mooshroom.cpp @@ -65,7 +65,7 @@ void cMooshroom::OnRightClicked(cPlayer & a_Player) } cItems Drops; - Drops.emplace_back(E_BLOCK_RED_MUSHROOM, 5, 0); + Drops.emplace_back(E_BLOCK_RED_MUSHROOM, char(5), char(0)); m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); m_World->SpawnMob(GetPosX(), GetPosY(), GetPosZ(), mtCow, false); Destroy(); diff --git a/src/Mobs/Pig.cpp b/src/Mobs/Pig.cpp index 88f3795c1..dc26caca9 100644 --- a/src/Mobs/Pig.cpp +++ b/src/Mobs/Pig.cpp @@ -34,7 +34,7 @@ void cPig::GetDrops(cItems & a_Drops, cEntity * a_Killer) AddRandomDropItem(a_Drops, 1, 3 + LootingLevel, IsOnFire() ? E_ITEM_COOKED_PORKCHOP : E_ITEM_RAW_PORKCHOP); if (m_bIsSaddled) { - a_Drops.emplace_back(E_ITEM_SADDLE, 1); + a_Drops.emplace_back(E_ITEM_SADDLE, char(1)); } } diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp index 156046c74..14d8dd8d8 100644 --- a/src/Mobs/Sheep.cpp +++ b/src/Mobs/Sheep.cpp @@ -42,7 +42,7 @@ void cSheep::GetDrops(cItems & a_Drops, cEntity * a_Killer) if (!m_IsSheared) { - a_Drops.emplace_back(E_BLOCK_WOOL, 1, static_cast(m_WoolColor)); + a_Drops.emplace_back(E_BLOCK_WOOL, char(1), static_cast(m_WoolColor)); } unsigned int LootingLevel = 0; diff --git a/src/OSSupport/IsThread.cpp b/src/OSSupport/IsThread.cpp index 28ed327f1..03ca2bfc4 100644 --- a/src/OSSupport/IsThread.cpp +++ b/src/OSSupport/IsThread.cpp @@ -114,7 +114,7 @@ void cIsThread::SetThreadName() const #pragma pack(pop) const DWORD NAME_EXCEPTION = 0x406D1388; - const THREADNAME_INFO Name = { 0x1000, m_ThreadName.c_str(), -1, 0 }; + const THREADNAME_INFO Name = { 0x1000, m_ThreadName.c_str(), static_cast(-1), 0 }; __try { diff --git a/src/Physics/Explodinator.cpp b/src/Physics/Explodinator.cpp index 72d050c59..7cd266c15 100644 --- a/src/Physics/Explodinator.cpp +++ b/src/Physics/Explodinator.cpp @@ -390,9 +390,9 @@ namespace Explodinator // Trace rays from the explosion centre to all points in a square of area TraceCubeSideLength * TraceCubeSideLength // for the top and bottom sides: - for (int OffsetX = -HalfSide; OffsetX < HalfSide; OffsetX++) + for (float OffsetX = -HalfSide; OffsetX < HalfSide; OffsetX++) { - for (int OffsetZ = -HalfSide; OffsetZ < HalfSide; OffsetZ++) + for (float OffsetZ = -HalfSide; OffsetZ < HalfSide; OffsetZ++) { DestructionTrace(&a_Chunk, a_Position, Vector3f(OffsetX, +HalfSide, OffsetZ), a_Power, a_Fiery, RandomIntensity(Random, a_Power), a_ExplodingEntity); DestructionTrace(&a_Chunk, a_Position, Vector3f(OffsetX, -HalfSide, OffsetZ), a_Power, a_Fiery, RandomIntensity(Random, a_Power), a_ExplodingEntity); @@ -400,9 +400,9 @@ namespace Explodinator } // Left and right sides, avoid duplicates at top and bottom edges: - for (int OffsetX = -HalfSide; OffsetX < HalfSide; OffsetX++) + for (float OffsetX = -HalfSide; OffsetX < HalfSide; OffsetX++) { - for (int OffsetY = -HalfSide + 1; OffsetY < HalfSide - 1; OffsetY++) + for (float OffsetY = -HalfSide + 1; OffsetY < HalfSide - 1; OffsetY++) { DestructionTrace(&a_Chunk, a_Position, Vector3f(OffsetX, OffsetY, +HalfSide), a_Power, a_Fiery, RandomIntensity(Random, a_Power), a_ExplodingEntity); DestructionTrace(&a_Chunk, a_Position, Vector3f(OffsetX, OffsetY, -HalfSide), a_Power, a_Fiery, RandomIntensity(Random, a_Power), a_ExplodingEntity); @@ -410,9 +410,9 @@ namespace Explodinator } // Front and back sides, avoid all edges: - for (int OffsetZ = -HalfSide + 1; OffsetZ < HalfSide - 1; OffsetZ++) + for (float OffsetZ = -HalfSide + 1; OffsetZ < HalfSide - 1; OffsetZ++) { - for (int OffsetY = -HalfSide + 1; OffsetY < HalfSide - 1; OffsetY++) + for (float OffsetY = -HalfSide + 1; OffsetY < HalfSide - 1; OffsetY++) { DestructionTrace(&a_Chunk, a_Position, Vector3f(+HalfSide, OffsetY, OffsetZ), a_Power, a_Fiery, RandomIntensity(Random, a_Power), a_ExplodingEntity); DestructionTrace(&a_Chunk, a_Position, Vector3f(-HalfSide, OffsetY, OffsetZ), a_Power, a_Fiery, RandomIntensity(Random, a_Power), a_ExplodingEntity); @@ -425,7 +425,7 @@ namespace Explodinator { for (const auto Client : a_Chunk.GetAllClients()) { - Client->SendExplosion(a_Position, a_Power); + Client->SendExplosion(a_Position, static_cast(a_Power)); } } diff --git a/src/Protocol/Protocol_1_8.cpp b/src/Protocol/Protocol_1_8.cpp index 012821c61..bf31c084c 100644 --- a/src/Protocol/Protocol_1_8.cpp +++ b/src/Protocol/Protocol_1_8.cpp @@ -374,7 +374,7 @@ void cProtocol_1_8_0::SendChatRaw(const AString & a_MessageRaw, eChatType a_Type // Send the json string to the client: cPacketizer Pkt(*this, pktChatRaw); Pkt.WriteString(a_MessageRaw); - Pkt.WriteBEInt8(a_Type); + Pkt.WriteBEInt8(static_cast(a_Type)); } diff --git a/src/Simulator/IncrementalRedstoneSimulator/RedstoneRepeaterHandler.h b/src/Simulator/IncrementalRedstoneSimulator/RedstoneRepeaterHandler.h index 521490023..8f5e8c1b7 100644 --- a/src/Simulator/IncrementalRedstoneSimulator/RedstoneRepeaterHandler.h +++ b/src/Simulator/IncrementalRedstoneSimulator/RedstoneRepeaterHandler.h @@ -23,7 +23,7 @@ namespace RedstoneRepeaterHandler if (!Chunk.UnboundedRelGetBlock(a_Position, Type, Meta)) { - return std::make_pair(false, 0); + return std::make_pair(false, static_cast(0)); } return std::make_pair(IsOn(Type), Meta); diff --git a/src/UI/BeaconWindow.cpp b/src/UI/BeaconWindow.cpp index d72eb5603..43addf630 100644 --- a/src/UI/BeaconWindow.cpp +++ b/src/UI/BeaconWindow.cpp @@ -67,8 +67,8 @@ void cBeaconWindow::OpenedByPlayer(cPlayer & a_Player) Super::OpenedByPlayer(a_Player); a_Player.GetClientHandle()->SendWindowProperty(*this, 0, m_Beacon->GetBeaconLevel()); - a_Player.GetClientHandle()->SendWindowProperty(*this, 1, m_Beacon->GetPrimaryEffect()); - a_Player.GetClientHandle()->SendWindowProperty(*this, 2, m_Beacon->GetSecondaryEffect()); + a_Player.GetClientHandle()->SendWindowProperty(*this, 1, static_cast(m_Beacon->GetPrimaryEffect())); + a_Player.GetClientHandle()->SendWindowProperty(*this, 2, static_cast(m_Beacon->GetSecondaryEffect())); } diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 0b060a5e4..bf328154d 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -399,7 +399,7 @@ bool cSlotArea::CollectItemsToHand(cItem & a_Dragging, cPlayer & a_Player, bool { continue; } - int ToMove = a_Dragging.GetMaxStackSize() - a_Dragging.m_ItemCount; + char ToMove = a_Dragging.GetMaxStackSize() - a_Dragging.m_ItemCount; if (ToMove > SlotItem.m_ItemCount) { ToMove = SlotItem.m_ItemCount; @@ -1167,7 +1167,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player) // Repair until out of materials, or fully repaired: while ((DamageDiff > 0) && (NumItemsConsumed < Sacrifice.m_ItemCount)) { - Output.m_ItemDamage -= DamageDiff; + Output.m_ItemDamage -= static_cast(DamageDiff); NeedExp += std::max(1, DamageDiff / 100) + static_cast(Target.m_Enchantments.Count()); DamageDiff = std::min(static_cast(Output.m_ItemDamage), static_cast(Target.GetMaxDamage()) / 4); diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 81704d6f0..89f3812d6 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -636,9 +636,9 @@ void cWindow::OnLeftPaintEnd(cPlayer & a_Player) const cSlotNums & SlotNums = a_Player.GetInventoryPaintSlots(); cItem ToDistribute(a_Player.GetDraggingItem()); - int ToEachSlot = static_cast(ToDistribute.m_ItemCount) / static_cast(SlotNums.size()); + char ToEachSlot = ToDistribute.m_ItemCount / static_cast(SlotNums.size()); - int NumDistributed = DistributeItemToSlots(a_Player, ToDistribute, ToEachSlot, SlotNums); + char NumDistributed = DistributeItemToSlots(a_Player, ToDistribute, ToEachSlot, SlotNums); // Remove the items distributed from the dragging item: a_Player.GetDraggingItem().m_ItemCount -= NumDistributed; @@ -666,7 +666,7 @@ void cWindow::OnRightPaintEnd(cPlayer & a_Player) const cSlotNums & SlotNums = a_Player.GetInventoryPaintSlots(); cItem ToDistribute(a_Player.GetDraggingItem()); - int NumDistributed = DistributeItemToSlots(a_Player, ToDistribute, 1, SlotNums); + char NumDistributed = DistributeItemToSlots(a_Player, ToDistribute, 1, SlotNums); // Remove the items distributed from the dragging item: a_Player.GetDraggingItem().m_ItemCount -= NumDistributed; @@ -710,7 +710,7 @@ void cWindow::OnMiddlePaintEnd(cPlayer & a_Player) -int cWindow::DistributeItemToSlots(cPlayer & a_Player, const cItem & a_Item, int a_NumToEachSlot, const cSlotNums & a_SlotNums, bool a_LimitItems) +char cWindow::DistributeItemToSlots(cPlayer & a_Player, const cItem & a_Item, char a_NumToEachSlot, const cSlotNums & a_SlotNums, bool a_LimitItems) { if (a_LimitItems && (static_cast(a_Item.m_ItemCount) < a_SlotNums.size())) { @@ -720,7 +720,7 @@ int cWindow::DistributeItemToSlots(cPlayer & a_Player, const cItem & a_Item, int } // Distribute to individual slots, keep track of how many items were actually distributed (full stacks etc.) - int NumDistributed = 0; + char NumDistributed = 0; for (cSlotNums::const_iterator itr = a_SlotNums.begin(), end = a_SlotNums.end(); itr != end; ++itr) { int LocalSlotNum = 0; @@ -733,19 +733,19 @@ int cWindow::DistributeItemToSlots(cPlayer & a_Player, const cItem & a_Item, int // Modify the item at the slot cItem AtSlot(*Area->GetSlot(LocalSlotNum, a_Player)); - int MaxStack = AtSlot.GetMaxStackSize(); + char MaxStack = AtSlot.GetMaxStackSize(); if (AtSlot.IsEmpty()) { // Empty, just move all of it there: cItem ToStore(a_Item); - ToStore.m_ItemCount = static_cast(std::min(a_NumToEachSlot, static_cast(MaxStack))); + ToStore.m_ItemCount = std::min(a_NumToEachSlot, MaxStack); Area->SetSlot(LocalSlotNum, a_Player, ToStore); NumDistributed += ToStore.m_ItemCount; } else if (AtSlot.IsEqual(a_Item)) { // Occupied, add and cap at MaxStack: - int CanStore = std::min(a_NumToEachSlot, static_cast(MaxStack) - AtSlot.m_ItemCount); + char CanStore = std::min(a_NumToEachSlot, MaxStack - AtSlot.m_ItemCount); AtSlot.m_ItemCount += CanStore; Area->SetSlot(LocalSlotNum, a_Player, AtSlot); NumDistributed += CanStore; diff --git a/src/UI/Window.h b/src/UI/Window.h index 46935acef..3b69b2da4 100644 --- a/src/UI/Window.h +++ b/src/UI/Window.h @@ -222,5 +222,5 @@ protected: /** Distributes a_NumToEachSlot items into the slots specified in a_SlotNums; returns the total number of items distributed. @param a_LimitItems if false, no checks are performed on a_Item.m_ItemCount. */ - int DistributeItemToSlots(cPlayer & a_Player, const cItem & a_Item, int a_NumToEachSlot, const cSlotNums & a_SlotNums, bool a_LimitItems = true); + char DistributeItemToSlots(cPlayer & a_Player, const cItem & a_Item, char a_NumToEachSlot, const cSlotNums & a_SlotNums, bool a_LimitItems = true); } ; // tolua_export diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index dde6c299c..c3d1eca77 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -1041,7 +1041,7 @@ public: mWriter.AddShort("xTile", static_cast(Arrow->GetBlockHit().x)); mWriter.AddShort("yTile", static_cast(Arrow->GetBlockHit().y)); mWriter.AddShort("zTile", static_cast(Arrow->GetBlockHit().z)); - mWriter.AddByte("pickup", Arrow->GetPickupState()); + mWriter.AddByte("pickup", static_cast(Arrow->GetPickupState())); mWriter.AddDouble("damage", Arrow->GetDamageCoeff()); break; } -- cgit v1.2.3