Fixed Compiler Warnings

This commit is contained in:
x12xx12x 2021-11-26 00:51:47 +01:00 committed by Alexander Harkness
parent b14874978a
commit 250b8eb652
34 changed files with 114 additions and 169 deletions

View File

@ -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<short>(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<short>(m_SecondaryEffect));
}
return true;
}

View File

@ -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

View File

@ -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<char>(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<char>(a_BlockFace), a_BlockType, a_BlockMeta);
}
private:

View File

@ -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<float>(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);
}

View File

@ -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<char>(a_Status)))
if (m_Player->IsFrozen() || PlgMgr->CallHookPlayerLeftClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, static_cast<char>(a_BlockFace), static_cast<char>(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<char>(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<char>(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<char>(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<char>(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<char>(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<char>(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<char>(a_BlockFace), a_CursorX, a_CursorY, a_CursorZ);
return;
}
}

View File

@ -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<unsigned char>((m_Color & COLOR_RED_BITS) >> COLOR_RED_OFFSET);
}

View File

@ -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<char>(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<cPlayer &>(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

View File

@ -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

View File

@ -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<size_t>(a_BiomeGroup) % ARRAYCOUNT(BiomeGroups);
size_t Index = a_BiomeIdx % BiomeGroups[Group].Count;

View File

@ -1822,7 +1822,7 @@ cFinishGenOres::OreInfos cFinishGenOres::OreInfosFromString(const AString & a_Or
);
continue;
}
auto oreType = BlockStringToType(parts[0]);
auto oreType = static_cast<BLOCKTYPE>(BlockStringToType(parts[0]));
if (oreType < 0)
{
LOGWARNING("Cannot parse ore information from string, invalid OreType: \"%s\".", parts[0].c_str());

View File

@ -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<int>(i), 0, m_AllWeights);
float BlockRnd = PieceNoise.IntNoise2DInRange(a_PieceRot, static_cast<int>(i), 0.0F, static_cast<float>(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<int>(PieceNoise.IntNoise2DInRange(a_PieceRot*2, static_cast<int>(i), blockToRnd.m_MinNoiseMeta, blockToRnd.m_MaxNoiseMeta)), blockToRnd.m_MinMeta, blockToRnd.m_MaxMeta);
char BlockMetaRnd = static_cast<char>(std::clamp<int>(static_cast<int>(PieceNoise.IntNoise2DInRange(a_PieceRot*2, static_cast<int>(i), static_cast<float>(blockToRnd.m_MinNoiseMeta), static_cast<float>(blockToRnd.m_MaxNoiseMeta))), blockToRnd.m_MinMeta, blockToRnd.m_MaxMeta));
BlockMetas[i] = static_cast<NIBBLETYPE>(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<int>(PieceNoise.IntNoise2DInRange(a_PieceRot*2, static_cast<int>(i), m_MinNoiseMeta, m_MaxNoiseMeta)), m_MinMeta, m_MaxMeta);
char BlockMetaRnd = static_cast<char>(std::clamp<int>(static_cast<int>(PieceNoise.IntNoise2DInRange(a_PieceRot * 2, static_cast<int>(i), static_cast<float>(m_MinNoiseMeta), static_cast<float>(m_MaxNoiseMeta))), m_MinMeta, m_MaxMeta));
BlockMetas[i] = static_cast<NIBBLETYPE>(BlockMetaRnd);
}
else if ((m_MaxMeta > -1) && (m_MaxMeta == m_MinMeta))

View File

@ -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<AString, cBlockArea::eMergeStrategy> & GetMergeStrategyMap(void)
{

View File

@ -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<HEIGHTTYPE>(a_BlockPos.y);
// Optional size-1 bottom leaves layer:
if ((MyRandom & 1) == 0)

View File

@ -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:

View File

@ -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:

View File

@ -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);

View File

@ -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);

View File

@ -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<char>(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<int>(m_Slots[i].m_ItemCount));
char NumToRemove = std::min<char>(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);
}

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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<unsigned int>(a_Min, a_Max);
auto MaxStackSize = static_cast<unsigned char>(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);
}
}

View File

@ -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();

View File

@ -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));
}
}

View File

@ -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<short>(m_WoolColor));
a_Drops.emplace_back(E_BLOCK_WOOL, char(1), static_cast<short>(m_WoolColor));
}
unsigned int LootingLevel = 0;

View File

@ -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<DWORD>(-1), 0 };
__try
{

View File

@ -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<float>(a_Power));
}
}

View File

@ -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<signed char>(a_Type));
}

View File

@ -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<NIBBLETYPE>(0));
}
return std::make_pair(IsOn(Type), Meta);

View File

@ -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<short>(m_Beacon->GetPrimaryEffect()));
a_Player.GetClientHandle()->SendWindowProperty(*this, 2, static_cast<short>(m_Beacon->GetSecondaryEffect()));
}

View File

@ -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<char>(DamageDiff);
NeedExp += std::max(1, DamageDiff / 100) + static_cast<int>(Target.m_Enchantments.Count());
DamageDiff = std::min(static_cast<int>(Output.m_ItemDamage), static_cast<int>(Target.GetMaxDamage()) / 4);

View File

@ -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<int>(ToDistribute.m_ItemCount) / static_cast<int>(SlotNums.size());
char ToEachSlot = ToDistribute.m_ItemCount / static_cast<char>(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<size_t>(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<char>(std::min(a_NumToEachSlot, static_cast<int>(MaxStack)));
ToStore.m_ItemCount = std::min<char>(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<int>(MaxStack) - AtSlot.m_ItemCount);
char CanStore = std::min<char>(a_NumToEachSlot, MaxStack - AtSlot.m_ItemCount);
AtSlot.m_ItemCount += CanStore;
Area->SetSlot(LocalSlotNum, a_Player, AtSlot);
NumDistributed += CanStore;

View File

@ -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

View File

@ -1041,7 +1041,7 @@ public:
mWriter.AddShort("xTile", static_cast<Int16>(Arrow->GetBlockHit().x));
mWriter.AddShort("yTile", static_cast<Int16>(Arrow->GetBlockHit().y));
mWriter.AddShort("zTile", static_cast<Int16>(Arrow->GetBlockHit().z));
mWriter.AddByte("pickup", Arrow->GetPickupState());
mWriter.AddByte("pickup", static_cast<unsigned char>(Arrow->GetPickupState()));
mWriter.AddDouble("damage", Arrow->GetDamageCoeff());
break;
}