summaryrefslogtreecommitdiffstats
path: root/src/WorldStorage
diff options
context:
space:
mode:
authorSamuel Barney <samjbarney@gmail.com>2015-07-29 17:04:03 +0200
committerSamuel Barney <samjbarney@gmail.com>2015-07-29 17:49:30 +0200
commit804805d35a87c2acc9425d1762ad26b1ba2ec9ac (patch)
tree13b603c8bbf8177da92ce87f5413fb646d204f3f /src/WorldStorage
parentMerge pull request #2376 from mjhanninen/fix-freebsd-build (diff)
downloadcuberite-804805d35a87c2acc9425d1762ad26b1ba2ec9ac.tar
cuberite-804805d35a87c2acc9425d1762ad26b1ba2ec9ac.tar.gz
cuberite-804805d35a87c2acc9425d1762ad26b1ba2ec9ac.tar.bz2
cuberite-804805d35a87c2acc9425d1762ad26b1ba2ec9ac.tar.lz
cuberite-804805d35a87c2acc9425d1762ad26b1ba2ec9ac.tar.xz
cuberite-804805d35a87c2acc9425d1762ad26b1ba2ec9ac.tar.zst
cuberite-804805d35a87c2acc9425d1762ad26b1ba2ec9ac.zip
Diffstat (limited to 'src/WorldStorage')
-rw-r--r--src/WorldStorage/CMakeLists.txt14
-rw-r--r--src/WorldStorage/FastNBT.cpp20
-rw-r--r--src/WorldStorage/MapSerializer.cpp10
-rw-r--r--src/WorldStorage/NBTChunkSerializer.cpp150
-rw-r--r--src/WorldStorage/SchematicFileSerializer.cpp10
-rwxr-xr-xsrc/WorldStorage/WSSAnvil.cpp122
6 files changed, 161 insertions, 165 deletions
diff --git a/src/WorldStorage/CMakeLists.txt b/src/WorldStorage/CMakeLists.txt
index 017d85f27..2192564e8 100644
--- a/src/WorldStorage/CMakeLists.txt
+++ b/src/WorldStorage/CMakeLists.txt
@@ -31,15 +31,11 @@ SET (HDRS
)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- set_source_files_properties(EnchantmentSerializer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
- set_source_files_properties(FastNBT.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=old-style-cast")
- set_source_files_properties(FireworksSerializer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum -Wno-error=old-style-cast")
- set_source_files_properties(MapSerializer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
- set_source_files_properties(NBTChunkSerializer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum -Wno-error=sign-conversion -Wno-error=conversion -Wno-error=old-style-cast")
- set_source_files_properties(SchematicFileSerializer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=shadow -Wno-error=conversion -Wno-error=old-style-cast -Wno-error=global-constructors")
- set_source_files_properties(ScoreboardSerializer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
- set_source_files_properties(WSSAnvil.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=shorten-64-to-32 -Wno-error=switch -Wno-error=switch-enum -Wno-error=conversion -Wno-error=old-style-cast")
- set_source_files_properties(WorldStorage.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
+ set_source_files_properties(FastNBT.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion ")
+ set_source_files_properties(FireworksSerializer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum ")
+ set_source_files_properties(NBTChunkSerializer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum -Wno-error=sign-conversion -Wno-error=conversion ")
+ set_source_files_properties(SchematicFileSerializer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=shadow -Wno-error=conversion -Wno-error=global-constructors")
+ set_source_files_properties(WSSAnvil.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=shorten-64-to-32 -Wno-error=switch -Wno-error=switch-enum -Wno-error=conversion ")
endif()
if(NOT MSVC)
diff --git a/src/WorldStorage/FastNBT.cpp b/src/WorldStorage/FastNBT.cpp
index 860eb3a4a..35c3ace0b 100644
--- a/src/WorldStorage/FastNBT.cpp
+++ b/src/WorldStorage/FastNBT.cpp
@@ -36,7 +36,7 @@ static const int MAX_LIST_ITEMS = 10000;
// cParsedNBT:
#define NEEDBYTES(N) \
- if (m_Length - m_Pos < (size_t)N) \
+ if (m_Length - m_Pos < static_cast<size_t>(N)) \
{ \
return false; \
}
@@ -90,7 +90,7 @@ bool cParsedNBT::ReadString(size_t & a_StringStart, size_t & a_StringLen)
{
NEEDBYTES(2);
a_StringStart = m_Pos + 2;
- a_StringLen = (size_t)GetBEShort(m_Data + m_Pos);
+ a_StringLen = static_cast<size_t>(GetBEShort(m_Data + m_Pos));
if (a_StringLen > 0xffff)
{
// Suspicious string length
@@ -114,7 +114,7 @@ bool cParsedNBT::ReadCompound(void)
for (;;)
{
NEEDBYTES(1);
- eTagType TagType = (eTagType)(m_Data[m_Pos]);
+ eTagType TagType = static_cast<eTagType>(m_Data[m_Pos]);
m_Pos++;
if (TagType == TAG_End)
{
@@ -123,13 +123,13 @@ bool cParsedNBT::ReadCompound(void)
m_Tags.push_back(cFastNBTTag(TagType, static_cast<int>(ParentIdx), PrevSibling));
if (PrevSibling >= 0)
{
- m_Tags[static_cast<size_t>(PrevSibling)].m_NextSibling = (int)m_Tags.size() - 1;
+ m_Tags[static_cast<size_t>(PrevSibling)].m_NextSibling = static_cast<int>(m_Tags.size()) - 1;
}
else
{
- m_Tags[ParentIdx].m_FirstChild = (int)m_Tags.size() - 1;
+ m_Tags[ParentIdx].m_FirstChild = static_cast<int>(m_Tags.size()) - 1;
}
- PrevSibling = (int)m_Tags.size() - 1;
+ PrevSibling = static_cast<int>(m_Tags.size()) - 1;
RETURN_FALSE_IF_FALSE(ReadString(m_Tags.back().m_NameStart, m_Tags.back().m_NameLength));
RETURN_FALSE_IF_FALSE(ReadTag());
} // while (true)
@@ -349,7 +349,7 @@ cFastNBTWriter::cFastNBTWriter(const AString & a_RootTagName) :
m_Stack[0].m_Type = TAG_Compound;
m_Result.reserve(100 * 1024);
m_Result.push_back(TAG_Compound);
- WriteString(a_RootTagName.data(), (UInt16)a_RootTagName.size());
+ WriteString(a_RootTagName.data(), static_cast<UInt16>(a_RootTagName.size()));
}
@@ -397,12 +397,12 @@ void cFastNBTWriter::BeginList(const AString & a_Name, eTagType a_ChildrenType)
TagCommon(a_Name, TAG_List);
- m_Result.push_back((char)a_ChildrenType);
- m_Result.append(4, (char)0);
+ m_Result.push_back(static_cast<char>(a_ChildrenType));
+ m_Result.append(4, static_cast<char>(0));
++m_CurrentStack;
m_Stack[m_CurrentStack].m_Type = TAG_List;
- m_Stack[m_CurrentStack].m_Pos = (int)m_Result.size() - 4;
+ m_Stack[m_CurrentStack].m_Pos = static_cast<int>(m_Result.size()) - 4;
m_Stack[m_CurrentStack].m_Count = 0;
m_Stack[m_CurrentStack].m_ItemType = a_ChildrenType;
}
diff --git a/src/WorldStorage/MapSerializer.cpp b/src/WorldStorage/MapSerializer.cpp
index d4925dcab..8acfa4696 100644
--- a/src/WorldStorage/MapSerializer.cpp
+++ b/src/WorldStorage/MapSerializer.cpp
@@ -112,7 +112,7 @@ void cMapSerializer::SaveMapToNBT(cFastNBTWriter & a_Writer)
a_Writer.AddInt("zCenter", m_Map->GetCenterZ());
const cMap::cColorList & Data = m_Map->GetData();
- a_Writer.AddByteArray("colors", (char *)Data.data(), Data.size());
+ a_Writer.AddByteArray("colors", reinterpret_cast<const char *>(Data.data()), Data.size());
a_Writer.EndCompound();
}
@@ -132,14 +132,14 @@ bool cMapSerializer::LoadMapFromNBT(const cParsedNBT & a_NBT)
int CurrLine = a_NBT.FindChildByName(Data, "scale");
if ((CurrLine >= 0) && (a_NBT.GetType(CurrLine) == TAG_Byte))
{
- unsigned int Scale = (unsigned int)a_NBT.GetByte(CurrLine);
+ unsigned int Scale = static_cast<unsigned int>(a_NBT.GetByte(CurrLine));
m_Map->SetScale(Scale);
}
CurrLine = a_NBT.FindChildByName(Data, "dimension");
if ((CurrLine >= 0) && (a_NBT.GetType(CurrLine) == TAG_Byte))
{
- eDimension Dimension = (eDimension) a_NBT.GetByte(CurrLine);
+ eDimension Dimension = static_cast<eDimension>(a_NBT.GetByte(CurrLine));
if (Dimension != m_Map->m_World->GetDimension())
{
@@ -151,7 +151,7 @@ bool cMapSerializer::LoadMapFromNBT(const cParsedNBT & a_NBT)
CurrLine = a_NBT.FindChildByName(Data, "width");
if ((CurrLine >= 0) && (a_NBT.GetType(CurrLine) == TAG_Short))
{
- unsigned int Width = (unsigned int)a_NBT.GetShort(CurrLine);
+ unsigned int Width = static_cast<unsigned int>(a_NBT.GetShort(CurrLine));
if (Width != 128)
{
return false;
@@ -162,7 +162,7 @@ bool cMapSerializer::LoadMapFromNBT(const cParsedNBT & a_NBT)
CurrLine = a_NBT.FindChildByName(Data, "height");
if ((CurrLine >= 0) && (a_NBT.GetType(CurrLine) == TAG_Short))
{
- unsigned int Height = (unsigned int)a_NBT.GetShort(CurrLine);
+ unsigned int Height = static_cast<unsigned int>(a_NBT.GetShort(CurrLine));
if (Height >= 256)
{
return false;
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index cfbbcd0b4..f204ec52b 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -92,12 +92,12 @@ void cNBTChunkSerializer::Finish(void)
void cNBTChunkSerializer::AddItem(const cItem & a_Item, int a_Slot, const AString & a_CompoundName)
{
m_Writer.BeginCompound(a_CompoundName);
- m_Writer.AddShort("id", (short)(a_Item.m_ItemType));
- m_Writer.AddShort("Damage", a_Item.m_ItemDamage);
- m_Writer.AddByte ("Count", a_Item.m_ItemCount);
+ m_Writer.AddShort("id", static_cast<Int16>(a_Item.m_ItemType));
+ m_Writer.AddShort("Damage", static_cast<Int16>((a_Item.m_ItemDamage)));
+ m_Writer.AddByte ("Count", static_cast<Byte>(a_Item.m_ItemCount));
if (a_Slot >= 0)
{
- m_Writer.AddByte ("Slot", (unsigned char)a_Slot);
+ m_Writer.AddByte ("Slot", static_cast<unsigned char>(a_Slot));
}
// Write the tag compound (for enchantment, firework, custom name and repair cost):
@@ -131,7 +131,7 @@ void cNBTChunkSerializer::AddItem(const cItem & a_Item, int a_Slot, const AStrin
if ((a_Item.m_ItemType == E_ITEM_FIREWORK_ROCKET) || (a_Item.m_ItemType == E_ITEM_FIREWORK_STAR))
{
- cFireworkItem::WriteToNBTCompound(a_Item.m_FireworkItem, m_Writer, (ENUM_ITEM_ID)a_Item.m_ItemType);
+ cFireworkItem::WriteToNBTCompound(a_Item.m_FireworkItem, m_Writer, static_cast<ENUM_ITEM_ID>(a_Item.m_ItemType));
}
if (!a_Item.m_Enchantments.IsEmpty())
@@ -184,8 +184,8 @@ void cNBTChunkSerializer::AddBeaconEntity(cBeaconEntity * a_Entity)
m_Writer.BeginCompound("");
AddBasicTileEntity(a_Entity, "Beacon");
m_Writer.AddInt("Levels", a_Entity->GetBeaconLevel());
- m_Writer.AddInt("Primary", (int)a_Entity->GetPrimaryEffect());
- m_Writer.AddInt("Secondary", (int)a_Entity->GetSecondaryEffect());
+ m_Writer.AddInt("Primary", static_cast<int>(a_Entity->GetPrimaryEffect()));
+ m_Writer.AddInt("Secondary", static_cast<int>(a_Entity->GetSecondaryEffect()));
m_Writer.BeginList("Items", TAG_Compound);
AddItemGrid(a_Entity->GetContents());
m_Writer.EndList();
@@ -245,8 +245,8 @@ void cNBTChunkSerializer::AddFurnaceEntity(cFurnaceEntity * a_Furnace)
m_Writer.BeginList("Items", TAG_Compound);
AddItemGrid(a_Furnace->GetContents());
m_Writer.EndList();
- m_Writer.AddShort("BurnTime", a_Furnace->GetFuelBurnTimeLeft());
- m_Writer.AddShort("CookTime", a_Furnace->GetTimeCooked());
+ m_Writer.AddShort("BurnTime", static_cast<Int16>(a_Furnace->GetFuelBurnTimeLeft()));
+ m_Writer.AddShort("CookTime", static_cast<Int16>(a_Furnace->GetTimeCooked()));
m_Writer.EndCompound();
}
@@ -298,7 +298,7 @@ void cNBTChunkSerializer::AddNoteEntity(cNoteEntity * a_Note)
{
m_Writer.BeginCompound("");
AddBasicTileEntity(a_Note, "Music");
- m_Writer.AddByte("note", a_Note->GetPitch());
+ m_Writer.AddByte("note", static_cast<Byte>(a_Note->GetPitch()));
m_Writer.EndCompound();
}
@@ -354,8 +354,8 @@ void cNBTChunkSerializer::AddFlowerPotEntity(cFlowerPotEntity * a_FlowerPot)
{
m_Writer.BeginCompound("");
AddBasicTileEntity(a_FlowerPot, "FlowerPot");
- m_Writer.AddInt ("Item", (Int32) a_FlowerPot->GetItem().m_ItemType);
- m_Writer.AddInt ("Data", (Int32) a_FlowerPot->GetItem().m_ItemDamage);
+ m_Writer.AddInt ("Item", static_cast<Int32>(a_FlowerPot->GetItem().m_ItemType));
+ m_Writer.AddInt ("Data", static_cast<Int32>(a_FlowerPot->GetItem().m_ItemDamage));
m_Writer.EndCompound();
}
@@ -380,7 +380,7 @@ void cNBTChunkSerializer::AddBasicEntity(cEntity * a_Entity, const AString & a_C
m_Writer.AddDouble("", a_Entity->GetYaw());
m_Writer.AddDouble("", a_Entity->GetPitch());
m_Writer.EndList();
- m_Writer.AddShort("Health", a_Entity->GetHealth());
+ m_Writer.AddShort("Health", static_cast<Int16>(a_Entity->GetHealth()));
}
@@ -435,7 +435,7 @@ void cNBTChunkSerializer::AddMinecartEntity(cMinecart * a_Minecart)
{
AddBasicEntity(a_Minecart, "MinecartChest");
// Add chest contents into the Items tag:
- AddMinecartChestContents((cMinecartWithChest *)a_Minecart);
+ AddMinecartChestContents(reinterpret_cast<cMinecartWithChest *>(a_Minecart));
break;
}
case cMinecart::mpFurnace:
@@ -521,9 +521,9 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
m_Writer.AddFloat("", a_Monster->GetDropChanceLeggings());
m_Writer.AddFloat("", a_Monster->GetDropChanceBoots());
m_Writer.EndList();
- m_Writer.AddByte("CanPickUpLoot", (char)a_Monster->CanPickUpLoot());
+ m_Writer.AddByte("CanPickUpLoot", (a_Monster->CanPickUpLoot())? 1 : 0);
m_Writer.AddString("CustomName", a_Monster->GetCustomName());
- m_Writer.AddByte("CustomNameVisible", (char)a_Monster->IsCustomNameAlwaysVisible());
+ m_Writer.AddByte("CustomNameVisible", static_cast<Byte>(a_Monster->IsCustomNameAlwaysVisible()));
switch (a_Monster->GetMobType())
{
case mtBat:
@@ -541,22 +541,22 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
case mtEnderman:
{
const cEnderman *Enderman = reinterpret_cast<const cEnderman *>(a_Monster);
- m_Writer.AddShort("carried", (Int16) Enderman->GetCarriedBlock());
- m_Writer.AddShort("carriedData", (Int16) Enderman->GetCarriedMeta());
+ m_Writer.AddShort("carried", static_cast<Int16>(Enderman->GetCarriedBlock()));
+ m_Writer.AddShort("carriedData", static_cast<Int16>(Enderman->GetCarriedMeta()));
break;
}
case mtHorse:
{
const cHorse *Horse = reinterpret_cast<const cHorse *>(a_Monster);
- m_Writer.AddByte("ChestedHorse", Horse->IsChested());
- m_Writer.AddByte("EatingHaystack", Horse->IsEating());
- m_Writer.AddByte("Tame", Horse->IsTame());
+ m_Writer.AddByte("ChestedHorse", Horse->IsChested()? 1 : 0);
+ m_Writer.AddByte("EatingHaystack", Horse->IsEating()? 1 : 0);
+ m_Writer.AddByte("Tame", Horse->IsTame()? 1: 0);
m_Writer.AddInt ("Type", Horse->GetHorseType());
m_Writer.AddInt ("Color", Horse->GetHorseColor());
m_Writer.AddInt ("Style", Horse->GetHorseStyle());
m_Writer.AddInt ("ArmorType", Horse->GetHorseArmour());
- m_Writer.AddByte("Saddle", Horse->IsSaddled());
- m_Writer.AddByte("Age", Horse->GetAge());
+ m_Writer.AddByte("Saddle", Horse->IsSaddled()? 1 : 0);
+ m_Writer.AddByte("Age", static_cast<Byte>(Horse->GetAge()));
break;
}
case mtMagmaCube:
@@ -567,9 +567,9 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
case mtSheep:
{
const cSheep *Sheep = reinterpret_cast<const cSheep *>(a_Monster);
- m_Writer.AddByte("Sheared", Sheep->IsSheared());
- m_Writer.AddByte("Color", Sheep->GetFurColor());
- m_Writer.AddByte("Age", Sheep->GetAge());
+ m_Writer.AddByte("Sheared", Sheep->IsSheared()? 1 : 0);
+ m_Writer.AddByte("Color", static_cast<Byte>(Sheep->GetFurColor()));
+ m_Writer.AddByte("Age", static_cast<Byte>(Sheep->GetAge()));
break;
}
case mtSlime:
@@ -586,12 +586,12 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
{
const cVillager *Villager = reinterpret_cast<const cVillager *>(a_Monster);
m_Writer.AddInt("Profession", Villager->GetVilType());
- m_Writer.AddByte("Age", Villager->GetAge());
+ m_Writer.AddByte("Age", static_cast<Byte>(Villager->GetAge()));
break;
}
case mtWither:
{
- m_Writer.AddInt("Invul", reinterpret_cast<const cWither *>(a_Monster)->GetWitherInvulnerableTicks());
+ m_Writer.AddInt("Invul", static_cast<Int32>(reinterpret_cast<const cWither *>(a_Monster)->GetWitherInvulnerableTicks()));
break;
}
case mtWolf:
@@ -607,8 +607,8 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
}
m_Writer.AddByte("Sitting", Wolf->IsSitting() ? 1 : 0);
m_Writer.AddByte("Angry", Wolf->IsAngry() ? 1 : 0);
- m_Writer.AddByte("CollarColor", (unsigned char) Wolf->GetCollarColor());
- m_Writer.AddByte("Age", Wolf->GetAge());
+ m_Writer.AddByte("CollarColor", static_cast<Byte>(Wolf->GetCollarColor()));
+ m_Writer.AddByte("Age", static_cast<Byte>(Wolf->GetAge()));
break;
}
case mtZombie:
@@ -616,22 +616,22 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
const cZombie *Zombie = reinterpret_cast<const cZombie *>(a_Monster);
m_Writer.AddByte("IsVillager", Zombie->IsVillagerZombie() ? 1 : 0);
m_Writer.AddByte("IsConverting", Zombie->IsConverting() ? 1 : 0);
- m_Writer.AddByte("Age", Zombie->GetAge());
+ m_Writer.AddByte("Age", static_cast<Byte>(Zombie->GetAge()));
break;
}
case mtZombiePigman:
{
- m_Writer.AddByte("Age", reinterpret_cast<const cZombiePigman *>(a_Monster)->GetAge());
+ m_Writer.AddByte("Age", static_cast<Byte>(reinterpret_cast<const cZombiePigman *>(a_Monster)->GetAge()));
break;
}
case mtOcelot:
{
- m_Writer.AddByte("Age", reinterpret_cast<const cOcelot *>(a_Monster)->GetAge());
+ m_Writer.AddByte("Age", static_cast<Byte>(reinterpret_cast<const cOcelot *>(a_Monster)->GetAge()));
break;
}
case mtPig:
{
- m_Writer.AddByte("Age", reinterpret_cast<const cPig *>(a_Monster)->GetAge());
+ m_Writer.AddByte("Age", static_cast<Byte>(reinterpret_cast<const cPig *>(a_Monster)->GetAge()));
break;
}
case mtRabbit:
@@ -639,7 +639,7 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
const cRabbit *Rabbit = reinterpret_cast<const cRabbit *>(a_Monster);
m_Writer.AddInt("RabbitType", Rabbit->GetRabbitTypeAsNumber());
m_Writer.AddInt("MoreCarrotTicks", Rabbit->GetMoreCarrotTicks());
- m_Writer.AddByte("Age", Rabbit->GetAge());
+ m_Writer.AddByte("Age", static_cast<Byte>(Rabbit->GetAge()));
break;
}
case mtInvalidType:
@@ -675,7 +675,7 @@ void cNBTChunkSerializer::AddPickupEntity(cPickup * a_Pickup)
m_Writer.BeginCompound("");
AddBasicEntity(a_Pickup, "Item");
AddItem(a_Pickup->GetItem(), -1, "Item");
- m_Writer.AddShort("Age", (Int16)a_Pickup->GetAge());
+ m_Writer.AddShort("Age", static_cast<Int16>(a_Pickup->GetAge()));
m_Writer.EndCompound();
}
@@ -693,21 +693,21 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile)
{
case cProjectileEntity::pkArrow:
{
- cArrowEntity * Arrow = (cArrowEntity *)a_Projectile;
+ cArrowEntity * Arrow = reinterpret_cast<cArrowEntity *>(a_Projectile);
- m_Writer.AddShort("xTile", (Int16)Arrow->GetBlockHit().x);
- m_Writer.AddShort("yTile", (Int16)Arrow->GetBlockHit().y);
- m_Writer.AddShort("zTile", (Int16)Arrow->GetBlockHit().z);
+ m_Writer.AddShort("xTile", static_cast<Int16>(Arrow->GetBlockHit().x));
+ m_Writer.AddShort("yTile", static_cast<Int16>(Arrow->GetBlockHit().y));
+ m_Writer.AddShort("zTile", static_cast<Int16>(Arrow->GetBlockHit().z));
m_Writer.AddByte("pickup", Arrow->GetPickupState());
m_Writer.AddDouble("damage", Arrow->GetDamageCoeff());
break;
}
case cProjectileEntity::pkSplashPotion:
{
- cSplashPotionEntity * Potion = (cSplashPotionEntity *)a_Projectile;
+ cSplashPotionEntity * Potion = reinterpret_cast<cSplashPotionEntity *>(a_Projectile);
- m_Writer.AddInt("EffectType", (Int16)Potion->GetEntityEffectType());
- m_Writer.AddInt("EffectDuration", (Int16)Potion->GetEntityEffect().GetDuration());
+ m_Writer.AddInt("EffectType", static_cast<Int16>(Potion->GetEntityEffectType()));
+ m_Writer.AddInt("EffectDuration", static_cast<Int16>(Potion->GetEntityEffect().GetDuration()));
m_Writer.AddShort("EffectIntensity", Potion->GetEntityEffect().GetIntensity());
m_Writer.AddDouble("EffectDistanceModifier", Potion->GetEntityEffect().GetDistanceModifier());
m_Writer.AddInt("PotionName", Potion->GetPotionColor());
@@ -757,7 +757,7 @@ void cNBTChunkSerializer::AddTNTEntity(cTNTEntity * a_TNT)
{
m_Writer.BeginCompound("");
AddBasicEntity(a_TNT, "PrimedTnt");
- m_Writer.AddByte("Fuse", (unsigned char)a_TNT->GetFuseTicks());
+ m_Writer.AddByte("Fuse", static_cast<unsigned char>(a_TNT->GetFuseTicks()));
m_Writer.EndCompound();
}
@@ -769,8 +769,8 @@ void cNBTChunkSerializer::AddExpOrbEntity(cExpOrb * a_ExpOrb)
{
m_Writer.BeginCompound("");
AddBasicEntity(a_ExpOrb, "XPOrb");
- m_Writer.AddShort("Age", (Int16)a_ExpOrb->GetAge());
- m_Writer.AddShort("Value", (Int16)a_ExpOrb->GetReward());
+ m_Writer.AddShort("Age", static_cast<Int16>(a_ExpOrb->GetAge()));
+ m_Writer.AddShort("Value", static_cast<Int16>(a_ExpOrb->GetReward()));
m_Writer.EndCompound();
}
@@ -784,7 +784,7 @@ void cNBTChunkSerializer::AddItemFrameEntity(cItemFrame * a_ItemFrame)
AddBasicEntity(a_ItemFrame, "ItemFrame");
AddHangingEntity(a_ItemFrame);
AddItem(a_ItemFrame->GetItem(), -1, "Item");
- m_Writer.AddByte("ItemRotation", (unsigned char)a_ItemFrame->GetItemRotation());
+ m_Writer.AddByte("ItemRotation", static_cast<Byte>(a_ItemFrame->GetItemRotation()));
m_Writer.AddFloat("ItemDropChance", 1.0F);
m_Writer.EndCompound();
}
@@ -858,7 +858,7 @@ void cNBTChunkSerializer::BiomeData(const cChunkDef::BiomeMap * a_BiomeMap)
if ((*a_BiomeMap)[i] < 255)
{
// Normal MC biome, copy as-is:
- m_VanillaBiomes[i] = (unsigned char)((*a_BiomeMap)[i]);
+ m_VanillaBiomes[i] = static_cast<Byte>((*a_BiomeMap)[i]);
}
else
{
@@ -894,17 +894,17 @@ void cNBTChunkSerializer::Entity(cEntity * a_Entity)
switch (a_Entity->GetEntityType())
{
- case cEntity::etBoat: AddBoatEntity ((cBoat *) a_Entity); break;
- case cEntity::etEnderCrystal: AddEnderCrystalEntity((cEnderCrystal *) a_Entity); break;
- case cEntity::etFallingBlock: AddFallingBlockEntity((cFallingBlock *) a_Entity); break;
- case cEntity::etMinecart: AddMinecartEntity ((cMinecart *) a_Entity); break;
- case cEntity::etMonster: AddMonsterEntity ((cMonster *) a_Entity); break;
- case cEntity::etPickup: AddPickupEntity ((cPickup *) a_Entity); break;
- case cEntity::etProjectile: AddProjectileEntity ((cProjectileEntity *)a_Entity); break;
- case cEntity::etTNT: AddTNTEntity ((cTNTEntity *) a_Entity); break;
- case cEntity::etExpOrb: AddExpOrbEntity ((cExpOrb *) a_Entity); break;
- case cEntity::etItemFrame: AddItemFrameEntity ((cItemFrame *) a_Entity); break;
- case cEntity::etPainting: AddPaintingEntity (reinterpret_cast<cPainting *>(a_Entity)); break;
+ case cEntity::etBoat: AddBoatEntity (reinterpret_cast<cBoat *> (a_Entity)); break;
+ case cEntity::etEnderCrystal: AddEnderCrystalEntity(reinterpret_cast<cEnderCrystal *> (a_Entity)); break;
+ case cEntity::etFallingBlock: AddFallingBlockEntity(reinterpret_cast<cFallingBlock *> (a_Entity)); break;
+ case cEntity::etMinecart: AddMinecartEntity (reinterpret_cast<cMinecart *> (a_Entity)); break;
+ case cEntity::etMonster: AddMonsterEntity (reinterpret_cast<cMonster *> (a_Entity)); break;
+ case cEntity::etPickup: AddPickupEntity (reinterpret_cast<cPickup *> (a_Entity)); break;
+ case cEntity::etProjectile: AddProjectileEntity (reinterpret_cast<cProjectileEntity *>(a_Entity)); break;
+ case cEntity::etTNT: AddTNTEntity (reinterpret_cast<cTNTEntity *> (a_Entity)); break;
+ case cEntity::etExpOrb: AddExpOrbEntity (reinterpret_cast<cExpOrb *> (a_Entity)); break;
+ case cEntity::etItemFrame: AddItemFrameEntity (reinterpret_cast<cItemFrame *> (a_Entity)); break;
+ case cEntity::etPainting: AddPaintingEntity (reinterpret_cast<cPainting *> (a_Entity)); break;
case cEntity::etPlayer: return; // Players aren't saved into the world
default:
{
@@ -937,23 +937,23 @@ void cNBTChunkSerializer::BlockEntity(cBlockEntity * a_Entity)
// Add tile-entity into NBT:
switch (a_Entity->GetBlockType())
{
- case E_BLOCK_BEACON: AddBeaconEntity ((cBeaconEntity *) a_Entity); break;
- case E_BLOCK_CHEST: AddChestEntity ((cChestEntity *) a_Entity, a_Entity->GetBlockType()); break;
- case E_BLOCK_COMMAND_BLOCK: AddCommandBlockEntity((cCommandBlockEntity *)a_Entity); break;
- case E_BLOCK_DISPENSER: AddDispenserEntity ((cDispenserEntity *) a_Entity); break;
- case E_BLOCK_DROPPER: AddDropperEntity ((cDropperEntity *) a_Entity); break;
+ case E_BLOCK_BEACON: AddBeaconEntity (reinterpret_cast<cBeaconEntity *> (a_Entity)); break;
+ case E_BLOCK_CHEST: AddChestEntity (reinterpret_cast<cChestEntity *> (a_Entity), a_Entity->GetBlockType()); break;
+ case E_BLOCK_COMMAND_BLOCK: AddCommandBlockEntity(reinterpret_cast<cCommandBlockEntity *>(a_Entity)); break;
+ case E_BLOCK_DISPENSER: AddDispenserEntity (reinterpret_cast<cDispenserEntity *> (a_Entity)); break;
+ case E_BLOCK_DROPPER: AddDropperEntity (reinterpret_cast<cDropperEntity *> (a_Entity)); break;
case E_BLOCK_ENDER_CHEST: /* No data to be saved */ break;
- case E_BLOCK_FLOWER_POT: AddFlowerPotEntity ((cFlowerPotEntity *) a_Entity); break;
- case E_BLOCK_FURNACE: AddFurnaceEntity ((cFurnaceEntity *) a_Entity); break;
- case E_BLOCK_HEAD: AddMobHeadEntity ((cMobHeadEntity *) a_Entity); break;
- case E_BLOCK_HOPPER: AddHopperEntity ((cHopperEntity *) a_Entity); break;
- case E_BLOCK_JUKEBOX: AddJukeboxEntity ((cJukeboxEntity *) a_Entity); break;
- case E_BLOCK_LIT_FURNACE: AddFurnaceEntity ((cFurnaceEntity *) a_Entity); break;
- case E_BLOCK_MOB_SPAWNER: AddMobSpawnerEntity ((cMobSpawnerEntity *) a_Entity); break;
- case E_BLOCK_NOTE_BLOCK: AddNoteEntity ((cNoteEntity *) a_Entity); break;
- case E_BLOCK_SIGN_POST: AddSignEntity ((cSignEntity *) a_Entity); break;
- case E_BLOCK_TRAPPED_CHEST: AddChestEntity ((cChestEntity *) a_Entity, a_Entity->GetBlockType()); break;
- case E_BLOCK_WALLSIGN: AddSignEntity ((cSignEntity *) a_Entity); break;
+ case E_BLOCK_FLOWER_POT: AddFlowerPotEntity (reinterpret_cast<cFlowerPotEntity *> (a_Entity)); break;
+ case E_BLOCK_FURNACE: AddFurnaceEntity (reinterpret_cast<cFurnaceEntity *> (a_Entity)); break;
+ case E_BLOCK_HEAD: AddMobHeadEntity (reinterpret_cast<cMobHeadEntity *> (a_Entity)); break;
+ case E_BLOCK_HOPPER: AddHopperEntity (reinterpret_cast<cHopperEntity *> (a_Entity)); break;
+ case E_BLOCK_JUKEBOX: AddJukeboxEntity (reinterpret_cast<cJukeboxEntity *> (a_Entity)); break;
+ case E_BLOCK_LIT_FURNACE: AddFurnaceEntity (reinterpret_cast<cFurnaceEntity *> (a_Entity)); break;
+ case E_BLOCK_MOB_SPAWNER: AddMobSpawnerEntity (reinterpret_cast<cMobSpawnerEntity *> (a_Entity)); break;
+ case E_BLOCK_NOTE_BLOCK: AddNoteEntity (reinterpret_cast<cNoteEntity *> (a_Entity)); break;
+ case E_BLOCK_SIGN_POST: AddSignEntity (reinterpret_cast<cSignEntity *> (a_Entity)); break;
+ case E_BLOCK_TRAPPED_CHEST: AddChestEntity (reinterpret_cast<cChestEntity *> (a_Entity), a_Entity->GetBlockType()); break;
+ case E_BLOCK_WALLSIGN: AddSignEntity (reinterpret_cast<cSignEntity *> (a_Entity)); break;
default:
{
diff --git a/src/WorldStorage/SchematicFileSerializer.cpp b/src/WorldStorage/SchematicFileSerializer.cpp
index 3e9ed5bef..6267668c5 100644
--- a/src/WorldStorage/SchematicFileSerializer.cpp
+++ b/src/WorldStorage/SchematicFileSerializer.cpp
@@ -271,13 +271,13 @@ bool cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, cP
AString cSchematicFileSerializer::SaveToSchematicNBT(const cBlockArea & a_BlockArea)
{
cFastNBTWriter Writer("Schematic");
- Writer.AddShort("Width", a_BlockArea.m_Size.x);
- Writer.AddShort("Height", a_BlockArea.m_Size.y);
- Writer.AddShort("Length", a_BlockArea.m_Size.z);
+ Writer.AddShort("Width", static_cast<Int16>(a_BlockArea.m_Size.x));
+ Writer.AddShort("Height", static_cast<Int16>(a_BlockArea.m_Size.y));
+ Writer.AddShort("Length", static_cast<Int16>(a_BlockArea.m_Size.z));
Writer.AddString("Materials", "Alpha");
if (a_BlockArea.HasBlockTypes())
{
- Writer.AddByteArray("Blocks", (const char *)a_BlockArea.m_BlockTypes, a_BlockArea.GetBlockCount());
+ Writer.AddByteArray("Blocks", reinterpret_cast<const char *>(a_BlockArea.m_BlockTypes), a_BlockArea.GetBlockCount());
}
else
{
@@ -286,7 +286,7 @@ AString cSchematicFileSerializer::SaveToSchematicNBT(const cBlockArea & a_BlockA
}
if (a_BlockArea.HasBlockMetas())
{
- Writer.AddByteArray("Data", (const char *)a_BlockArea.m_BlockMetas, a_BlockArea.GetBlockCount());
+ Writer.AddByteArray("Data", reinterpret_cast<const char *>(a_BlockArea.m_BlockMetas), a_BlockArea.GetBlockCount());
}
else
{
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 54071b9df..a4c9f4fbf 100755
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -78,7 +78,7 @@ Since only the header is actually in the memory, this number can be high, but st
"Please add the reported file and this message to the issue report.", \
__FUNCTION__, __LINE__, CHX, CHZ, RegionX, RegionZ \
); \
- *((volatile int *)0) = 0; /* Crash intentionally */ \
+ *(reinterpret_cast<volatile int *>(0)) = 0; /* Crash intentionally */ \
}
@@ -107,13 +107,13 @@ cWSSAnvil::cWSSAnvil(cWorld * a_World, int a_CompressionFactor) :
Writer.AddByte("MapFeatures", 1);
Writer.AddByte("raining", a_World->IsWeatherRain() ? 1 : 0);
Writer.AddByte("thundering", a_World->IsWeatherStorm() ? 1 : 0);
- Writer.AddInt("GameType", (int)a_World->GetGameMode());
+ Writer.AddInt("GameType", static_cast<int>(a_World->GetGameMode()));
Writer.AddInt("generatorVersion", 1);
- Writer.AddInt("SpawnX", (int)a_World->GetSpawnX());
- Writer.AddInt("SpawnY", (int)a_World->GetSpawnY());
- Writer.AddInt("SpawnZ", (int)a_World->GetSpawnZ());
+ Writer.AddInt("SpawnX", static_cast<int>(a_World->GetSpawnX()));
+ Writer.AddInt("SpawnY", static_cast<int>(a_World->GetSpawnY()));
+ Writer.AddInt("SpawnZ", static_cast<int>(a_World->GetSpawnZ()));
Writer.AddInt("version", 19133);
- Writer.AddLong("DayTime", (Int64)a_World->GetTimeOfDay());
+ Writer.AddLong("DayTime", static_cast<Int64>(a_World->GetTimeOfDay()));
Writer.AddLong("Time", a_World->GetWorldAge());
Writer.AddLong("SizeOnDisk", 0);
Writer.AddString("generatorName", "default");
@@ -366,10 +366,10 @@ bool cWSSAnvil::LoadChunkFromNBT(const cChunkCoords & a_Chunk, const cParsedNBT
{
continue;
}
- CopyNBTData(a_NBT, Child, "Blocks", (char *)&(BlockTypes[y * 4096]), 4096);
- CopyNBTData(a_NBT, Child, "Data", (char *)&(MetaData[y * 2048]), 2048);
- CopyNBTData(a_NBT, Child, "SkyLight", (char *)&(SkyLight[y * 2048]), 2048);
- CopyNBTData(a_NBT, Child, "BlockLight", (char *)&(BlockLight[y * 2048]), 2048);
+ CopyNBTData(a_NBT, Child, "Blocks", reinterpret_cast<char *>(&(BlockTypes[y * 4096])), 4096);
+ CopyNBTData(a_NBT, Child, "Data", reinterpret_cast<char *>(&(MetaData[y * 2048])), 2048);
+ CopyNBTData(a_NBT, Child, "SkyLight", reinterpret_cast<char *>(&(SkyLight[y * 2048])), 2048);
+ CopyNBTData(a_NBT, Child, "BlockLight", reinterpret_cast<char *>(&(BlockLight[y * 2048])), 2048);
} // for itr - LevelSections[]
// Load the biomes from NBT, if present and valid. First try MCS-style, then Vanilla-style:
@@ -471,32 +471,32 @@ bool cWSSAnvil::SaveChunkToNBT(const cChunkCoords & a_Chunk, cFastNBTWriter & a_
// Save biomes, both MCS (IntArray) and MC-vanilla (ByteArray):
if (Serializer.m_BiomesAreValid)
{
- a_Writer.AddByteArray("Biomes", (const char *)(Serializer.m_VanillaBiomes), ARRAYCOUNT(Serializer.m_VanillaBiomes));
- a_Writer.AddIntArray ("MCSBiomes", (const int *)(Serializer.m_Biomes), ARRAYCOUNT(Serializer.m_Biomes));
+ a_Writer.AddByteArray("Biomes", reinterpret_cast<const char *>(Serializer.m_VanillaBiomes), ARRAYCOUNT(Serializer.m_VanillaBiomes));
+ a_Writer.AddIntArray ("MCSBiomes", reinterpret_cast<const int *>(Serializer.m_Biomes), ARRAYCOUNT(Serializer.m_Biomes));
}
// Save heightmap (Vanilla require this):
- a_Writer.AddIntArray("HeightMap", (const int *)Serializer.m_VanillaHeightMap, ARRAYCOUNT(Serializer.m_VanillaHeightMap));
+ a_Writer.AddIntArray("HeightMap", reinterpret_cast<const int *>(Serializer.m_VanillaHeightMap), ARRAYCOUNT(Serializer.m_VanillaHeightMap));
// Save blockdata:
a_Writer.BeginList("Sections", TAG_Compound);
size_t SliceSizeBlock = cChunkDef::Width * cChunkDef::Width * 16;
size_t SliceSizeNibble = SliceSizeBlock / 2;
- const char * BlockTypes = (const char *)(Serializer.m_BlockTypes);
- const char * BlockMetas = (const char *)(Serializer.m_BlockMetas);
+ const char * BlockTypes = reinterpret_cast<const char *>(Serializer.m_BlockTypes);
+ const char * BlockMetas = reinterpret_cast<const char *>(Serializer.m_BlockMetas);
#ifdef DEBUG_SKYLIGHT
- const char * BlockLight = (const char *)(Serializer.m_BlockSkyLight);
+ const char * BlockLight = reinterpret_cast<const char *>(Serializer.m_BlockSkyLight);
#else
- const char * BlockLight = (const char *)(Serializer.m_BlockLight);
+ const char * BlockLight = reinterpret_cast<const char *>(Serializer.m_BlockLight);
#endif
- const char * BlockSkyLight = (const char *)(Serializer.m_BlockSkyLight);
+ const char * BlockSkyLight = reinterpret_cast<const char *>(Serializer.m_BlockSkyLight);
for (int Y = 0; Y < 16; Y++)
{
a_Writer.BeginCompound("");
- a_Writer.AddByteArray("Blocks", BlockTypes + Y * SliceSizeBlock, SliceSizeBlock);
- a_Writer.AddByteArray("Data", BlockMetas + Y * SliceSizeNibble, SliceSizeNibble);
- a_Writer.AddByteArray("SkyLight", BlockSkyLight + Y * SliceSizeNibble, SliceSizeNibble);
- a_Writer.AddByteArray("BlockLight", BlockLight + Y * SliceSizeNibble, SliceSizeNibble);
+ a_Writer.AddByteArray("Blocks", BlockTypes + static_cast<unsigned int>(Y) * SliceSizeBlock, SliceSizeBlock);
+ a_Writer.AddByteArray("Data", BlockMetas + static_cast<unsigned int>(Y) * SliceSizeNibble, SliceSizeNibble);
+ a_Writer.AddByteArray("SkyLight", BlockSkyLight + static_cast<unsigned int>(Y) * SliceSizeNibble, SliceSizeNibble);
+ a_Writer.AddByteArray("BlockLight", BlockLight + static_cast<unsigned int>(Y) * SliceSizeNibble, SliceSizeNibble);
a_Writer.AddByte("Y", static_cast<unsigned char>(Y));
a_Writer.EndCompound();
}
@@ -534,7 +534,7 @@ cChunkDef::BiomeMap * cWSSAnvil::LoadVanillaBiomeMapFromNBT(cChunkDef::BiomeMap
// The biomes stored don't match in size
return nullptr;
}
- const unsigned char * VanillaBiomeData = (const unsigned char *)(a_NBT.GetData(a_TagIdx));
+ const unsigned char * VanillaBiomeData = reinterpret_cast<const unsigned char *>(a_NBT.GetData(a_TagIdx));
for (size_t i = 0; i < ARRAYCOUNT(*a_BiomeMap); i++)
{
if ((VanillaBiomeData)[i] == 0xff)
@@ -542,7 +542,7 @@ cChunkDef::BiomeMap * cWSSAnvil::LoadVanillaBiomeMapFromNBT(cChunkDef::BiomeMap
// Unassigned biomes
return nullptr;
}
- (*a_BiomeMap)[i] = (EMCSBiome)(VanillaBiomeData[i]);
+ (*a_BiomeMap)[i] = static_cast<EMCSBiome>(VanillaBiomeData[i]);
}
return a_BiomeMap;
}
@@ -565,7 +565,7 @@ cChunkDef::BiomeMap * cWSSAnvil::LoadBiomeMapFromNBT(cChunkDef::BiomeMap * a_Bio
const char * BiomeData = (a_NBT.GetData(a_TagIdx));
for (size_t i = 0; i < ARRAYCOUNT(*a_BiomeMap); i++)
{
- (*a_BiomeMap)[i] = (EMCSBiome)(GetBEInt(&BiomeData[i * 4]));
+ (*a_BiomeMap)[i] = static_cast<EMCSBiome>(GetBEInt(&BiomeData[i * 4]));
if ((*a_BiomeMap)[i] == 0xff)
{
// Unassigned biomes
@@ -682,7 +682,7 @@ cBlockEntity * cWSSAnvil::LoadBlockEntityFromNBT(const cParsedNBT & a_NBT, int a
AString TypeName("<unknown>");
if (TagID >= 0)
{
- TypeName.assign(a_NBT.GetData(TagID), (size_t)a_NBT.GetDataLength(TagID));
+ TypeName.assign(a_NBT.GetData(TagID), static_cast<size_t>(a_NBT.GetDataLength(TagID)));
}
LOGINFO("WorldLoader(%s): Block entity mismatch: block type %s (%d), type \"%s\", at {%d, %d, %d}; the entity will be lost.",
m_World->GetName().c_str(),
@@ -736,7 +736,7 @@ bool cWSSAnvil::LoadItemFromNBT(cItem & a_Item, const cParsedNBT & a_NBT, int a_
int Count = a_NBT.FindChildByName(a_TagIdx, "Count");
if ((Count > 0) && (a_NBT.GetType(Count) == TAG_Byte))
{
- a_Item.m_ItemCount = a_NBT.GetByte(Count);
+ a_Item.m_ItemCount = static_cast<char>(a_NBT.GetByte(Count));
}
// Find the "tag" tag, used for enchantments and other extra data
@@ -782,7 +782,7 @@ bool cWSSAnvil::LoadItemFromNBT(cItem & a_Item, const cParsedNBT & a_NBT, int a_
int FireworksTag = a_NBT.FindChildByName(TagTag, ((a_Item.m_ItemType == E_ITEM_FIREWORK_STAR) ? "Fireworks" : "Explosion"));
if (EnchTag > 0)
{
- cFireworkItem::ParseFromNBT(a_Item.m_FireworkItem, a_NBT, FireworksTag, (ENUM_ITEM_ID)a_Item.m_ItemType);
+ cFireworkItem::ParseFromNBT(a_Item.m_FireworkItem, a_NBT, FireworksTag, static_cast<ENUM_ITEM_ID>(a_Item.m_ItemType));
}
return true;
@@ -802,7 +802,7 @@ void cWSSAnvil::LoadItemGridFromNBT(cItemGrid & a_ItemGrid, const cParsedNBT & a
{
continue;
}
- int SlotNum = (int)(a_NBT.GetByte(SlotTag)) - a_SlotOffset;
+ int SlotNum = static_cast<int>(a_NBT.GetByte(SlotTag)) - a_SlotOffset;
if ((SlotNum < 0) || (SlotNum >= NumSlots))
{
// SlotNum outside of the range
@@ -836,13 +836,13 @@ bool cWSSAnvil::CheckBlockEntityType(const cParsedNBT & a_NBT, int a_TagIdx, con
}
// Compare the value:
- if (strncmp(a_NBT.GetData(TagID), a_ExpectedType, (size_t)a_NBT.GetDataLength(TagID)) == 0)
+ if (strncmp(a_NBT.GetData(TagID), a_ExpectedType, static_cast<size_t>(a_NBT.GetDataLength(TagID))) == 0)
{
return true;
}
LOGWARNING("Block entity type mismatch: exp \"%s\", got \"%s\".",
a_ExpectedType,
- AString(a_NBT.GetData(TagID), (size_t)a_NBT.GetDataLength(TagID)).c_str()
+ AString(a_NBT.GetData(TagID), static_cast<size_t>(a_NBT.GetDataLength(TagID))).c_str()
);
return false;
}
@@ -864,19 +864,19 @@ cBlockEntity * cWSSAnvil::LoadBeaconFromNBT(const cParsedNBT & a_NBT, int a_TagI
int CurrentLine = a_NBT.FindChildByName(a_TagIdx, "Levels");
if (CurrentLine >= 0)
{
- Beacon->SetBeaconLevel((char)a_NBT.GetInt(CurrentLine));
+ Beacon->SetBeaconLevel(static_cast<char>(a_NBT.GetInt(CurrentLine)));
}
CurrentLine = a_NBT.FindChildByName(a_TagIdx, "Primary");
if (CurrentLine >= 0)
{
- Beacon->SetPrimaryEffect((cEntityEffect::eType)a_NBT.GetInt(CurrentLine));
+ Beacon->SetPrimaryEffect(static_cast<cEntityEffect::eType>(a_NBT.GetInt(CurrentLine)));
}
CurrentLine = a_NBT.FindChildByName(a_TagIdx, "Secondary");
if (CurrentLine >= 0)
{
- Beacon->SetSecondaryEffect((cEntityEffect::eType)a_NBT.GetInt(CurrentLine));
+ Beacon->SetSecondaryEffect(static_cast<cEntityEffect::eType>(a_NBT.GetInt(CurrentLine)));
}
// We are better than mojang, we load / save the beacon inventory!
@@ -937,7 +937,7 @@ cBlockEntity * cWSSAnvil::LoadCommandBlockFromNBT(const cParsedNBT & a_NBT, int
currentLine = a_NBT.FindChildByName(a_TagIdx, "SuccessCount");
if (currentLine >= 0)
{
- CmdBlock->SetResult(a_NBT.GetInt(currentLine));
+ CmdBlock->SetResult(static_cast<NIBBLETYPE>(a_NBT.GetInt(currentLine)));
}
currentLine = a_NBT.FindChildByName(a_TagIdx, "LastOutput");
@@ -1019,14 +1019,14 @@ cBlockEntity * cWSSAnvil::LoadFlowerPotFromNBT(const cParsedNBT & a_NBT, int a_T
}
else if (a_NBT.GetType(currentLine) == TAG_Int)
{
- Item.m_ItemType = (short) a_NBT.GetInt(currentLine);
+ Item.m_ItemType = static_cast<short>(a_NBT.GetInt(currentLine));
}
}
currentLine = a_NBT.FindChildByName(a_TagIdx, "Data");
if ((currentLine >= 0) && (a_NBT.GetType(currentLine) == TAG_Int))
{
- Item.m_ItemDamage = (short) a_NBT.GetInt(currentLine);
+ Item.m_ItemDamage = static_cast<short>(a_NBT.GetInt(currentLine));
}
FlowerPot->SetItem(Item);
@@ -1234,7 +1234,7 @@ cBlockEntity * cWSSAnvil::LoadNoteBlockFromNBT(const cParsedNBT & a_NBT, int a_T
int note = a_NBT.FindChildByName(a_TagIdx, "note");
if (note >= 0)
{
- NoteBlock->SetPitch(a_NBT.GetByte(note));
+ NoteBlock->SetPitch(static_cast<char>(a_NBT.GetByte(note)));
}
return NoteBlock.release();
}
@@ -1553,7 +1553,7 @@ void cWSSAnvil::LoadFallingBlockFromNBT(cEntityList & a_Entities, const cParsedN
}
int Type = a_NBT.GetInt(TypeIdx);
- NIBBLETYPE Meta = (NIBBLETYPE)a_NBT.GetByte(MetaIdx);
+ NIBBLETYPE Meta = static_cast<NIBBLETYPE>(a_NBT.GetByte(MetaIdx));
std::unique_ptr<cFallingBlock> FallingBlock = cpp14::make_unique<cFallingBlock>(Vector3i(0, 0, 0), Type, Meta);
if (!LoadEntityBaseFromNBT(*FallingBlock.get(), a_NBT, a_TagIdx))
@@ -1710,7 +1710,7 @@ void cWSSAnvil::LoadTNTFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB
int FuseTicks = a_NBT.FindChildByName(a_TagIdx, "Fuse");
if (FuseTicks > 0)
{
- TNT->SetFuseTicks((int) a_NBT.GetByte(FuseTicks));
+ TNT->SetFuseTicks(static_cast<int>(a_NBT.GetByte(FuseTicks)));
}
a_Entities.push_back(TNT.release());
@@ -1804,7 +1804,7 @@ void cWSSAnvil::LoadItemFrameFromNBT(cEntityList & a_Entities, const cParsedNBT
int Rotation = a_NBT.FindChildByName(a_TagIdx, "ItemRotation");
if (Rotation > 0)
{
- ItemFrame->SetItemRotation((Byte)a_NBT.GetByte(Rotation));
+ ItemFrame->SetItemRotation(static_cast<Byte>(a_NBT.GetByte(Rotation)));
}
a_Entities.push_back(ItemFrame.release());
@@ -1849,7 +1849,7 @@ void cWSSAnvil::LoadArrowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
int PickupIdx = a_NBT.FindChildByName(a_TagIdx, "pickup");
if ((PickupIdx > 0) && (a_NBT.GetType(PickupIdx) == TAG_Byte))
{
- Arrow->SetPickupState((cArrowEntity::ePickupState)a_NBT.GetByte(PickupIdx));
+ Arrow->SetPickupState(static_cast<cArrowEntity::ePickupState>(a_NBT.GetByte(PickupIdx)));
}
else
{
@@ -1888,7 +1888,7 @@ void cWSSAnvil::LoadArrowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
case TAG_Short:
{
// Vanilla uses this
- Arrow->SetBlockHit(Vector3i((int)a_NBT.GetShort(InBlockXIdx), (int)a_NBT.GetShort(InBlockYIdx), (int)a_NBT.GetShort(InBlockZIdx)));
+ Arrow->SetBlockHit(Vector3i(static_cast<int>(a_NBT.GetShort(InBlockXIdx)), static_cast<int>(a_NBT.GetShort(InBlockYIdx)), static_cast<int>(a_NBT.GetShort(InBlockZIdx))));
break;
}
default:
@@ -1919,8 +1919,8 @@ void cWSSAnvil::LoadSplashPotionFromNBT(cEntityList & a_Entities, const cParsedN
int EffectIntensity = a_NBT.FindChildByName(a_TagIdx, "EffectIntensity");
int EffectDistanceModifier = a_NBT.FindChildByName(a_TagIdx, "EffectDistanceModifier");
- SplashPotion->SetEntityEffectType((cEntityEffect::eType) a_NBT.FindChildByName(a_TagIdx, "EffectType"));
- SplashPotion->SetEntityEffect(cEntityEffect(EffectDuration, EffectIntensity, EffectDistanceModifier));
+ SplashPotion->SetEntityEffectType(static_cast<cEntityEffect::eType>(a_NBT.FindChildByName(a_TagIdx, "EffectType")));
+ SplashPotion->SetEntityEffect(cEntityEffect(EffectDuration, static_cast<Int16>(EffectIntensity), EffectDistanceModifier));
SplashPotion->SetPotionColor(a_NBT.FindChildByName(a_TagIdx, "PotionName"));
// Store the new splash potion in the entities list:
@@ -2261,7 +2261,7 @@ void cWSSAnvil::LoadHorseFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
if (AgeableIdx > 0)
{
Byte Age = a_NBT.GetByte(AgeableIdx);
- Monster->SetAge(Age);
+ Monster->SetAge(static_cast<char>(Age));
}
a_Entities.push_back(Monster.release());
@@ -2357,7 +2357,7 @@ void cWSSAnvil::LoadOcelotFromNBT(cEntityList & a_Entities, const cParsedNBT & a
if (AgeableIdx > 0)
{
Byte Age = a_NBT.GetByte(AgeableIdx);
- Monster->SetAge(Age);
+ Monster->SetAge(static_cast<char>(Age));
}
a_Entities.push_back(Monster.release());
@@ -2384,7 +2384,7 @@ void cWSSAnvil::LoadPigFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB
if (AgeableIdx > 0)
{
Byte Age = a_NBT.GetByte(AgeableIdx);
- Monster->SetAge(Age);
+ Monster->SetAge(static_cast<char>(Age));
}
a_Entities.push_back(Monster.release());
@@ -2422,7 +2422,7 @@ void cWSSAnvil::LoadRabbitFromNBT(cEntityList & a_Entities, const cParsedNBT & a
if (AgeableIdx > 0)
{
Byte Age = a_NBT.GetByte(AgeableIdx);
- Monster->SetAge(Age);
+ Monster->SetAge(static_cast<char>(Age));
}
a_Entities.push_back(Monster.release());
@@ -2438,7 +2438,7 @@ void cWSSAnvil::LoadSheepFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
int Color = -1;
if (ColorIdx > 0)
{
- Color = (int)a_NBT.GetByte(ColorIdx);
+ Color = static_cast<int>(a_NBT.GetByte(ColorIdx));
}
std::unique_ptr<cSheep> Monster = cpp14::make_unique<cSheep>(Color);
@@ -2462,7 +2462,7 @@ void cWSSAnvil::LoadSheepFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
if (AgeableIdx > 0)
{
Byte Age = a_NBT.GetByte(AgeableIdx);
- Monster->SetAge(Age);
+ Monster->SetAge(static_cast<char>(Age));
}
a_Entities.push_back(Monster.release());
@@ -2634,7 +2634,7 @@ void cWSSAnvil::LoadVillagerFromNBT(cEntityList & a_Entities, const cParsedNBT &
if (AgeableIdx > 0)
{
Byte Age = a_NBT.GetByte(AgeableIdx);
- Monster->SetAge(Age);
+ Monster->SetAge(static_cast<char>(Age));
}
@@ -2681,7 +2681,7 @@ void cWSSAnvil::LoadWitherFromNBT(cEntityList & a_Entities, const cParsedNBT & a
int CurrLine = a_NBT.FindChildByName(a_TagIdx, "Invul");
if (CurrLine > 0)
{
- Monster->SetWitherInvulnerableTicks(a_NBT.GetInt(CurrLine));
+ Monster->SetWitherInvulnerableTicks(static_cast<unsigned int>(a_NBT.GetInt(CurrLine)));
}
a_Entities.push_back(Monster.release());
@@ -2742,7 +2742,7 @@ void cWSSAnvil::LoadWolfFromNBT(cEntityList & a_Entities, const cParsedNBT & a_N
if (AgeableIdx > 0)
{
Byte Age = a_NBT.GetByte(AgeableIdx);
- Monster->SetAge(Age);
+ Monster->SetAge(static_cast<char>(Age));
}
a_Entities.push_back(Monster.release());
@@ -2777,7 +2777,7 @@ void cWSSAnvil::LoadZombieFromNBT(cEntityList & a_Entities, const cParsedNBT & a
if (AgeableIdx > 0)
{
Byte Age = a_NBT.GetByte(AgeableIdx);
- Monster->SetAge(Age);
+ Monster->SetAge(static_cast<char>(Age));
}
a_Entities.push_back(Monster.release());
@@ -2804,7 +2804,7 @@ void cWSSAnvil::LoadPigZombieFromNBT(cEntityList & a_Entities, const cParsedNBT
if (AgeableIdx > 0)
{
Byte Age = a_NBT.GetByte(AgeableIdx);
- Monster->SetAge(Age);
+ Monster->SetAge(static_cast<char>(Age));
}
a_Entities.push_back(Monster.release());
@@ -3138,7 +3138,7 @@ bool cWSSAnvil::cMCAFile::GetChunkData(const cChunkCoords & a_Chunk, AString & a
return false;
}
- m_File.Seek((int)ChunkOffset * 4096);
+ m_File.Seek(static_cast<int>(ChunkOffset) * 4096);
int ChunkSize = 0;
if (m_File.Read(&ChunkSize, 4) != 4)
@@ -3162,8 +3162,8 @@ bool cWSSAnvil::cMCAFile::GetChunkData(const cChunkCoords & a_Chunk, AString & a
ChunkSize--;
// HACK: This depends on the internal knowledge that AString's data() function returns the internal buffer directly
- a_Data.assign(ChunkSize, '\0');
- if (m_File.Read((void *)a_Data.data(), ChunkSize) == ChunkSize)
+ a_Data.assign(static_cast<size_t>(ChunkSize), '\0');
+ if (static_cast<size_t>(m_File.Read(static_cast<void *>(const_cast<char*>(a_Data.data())), static_cast<size_t>(ChunkSize))) == static_cast<size_t>(ChunkSize))
{
return true;
}
@@ -3197,7 +3197,7 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const AStri
unsigned ChunkSector = FindFreeLocation(LocalX, LocalZ, a_Data);
// Store the chunk data:
- m_File.Seek(ChunkSector * 4096);
+ m_File.Seek(static_cast<int>(ChunkSector * 4096));
u_long ChunkSize = htonl(static_cast<u_long>(a_Data.size()) + 1);
if (m_File.Write(&ChunkSize, 4) != 4)
{
@@ -3210,7 +3210,7 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const AStri
LOGWARNING("Cannot save chunk [%d, %d], writing(2) data to file \"%s\" failed", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, GetFileName().c_str());
return false;
}
- if (m_File.Write(a_Data.data(), a_Data.size()) != (int)(a_Data.size()))
+ if (m_File.Write(a_Data.data(), a_Data.size()) != static_cast<int>(a_Data.size()))
{
LOGWARNING("Cannot save chunk [%d, %d], writing(3) data to file \"%s\" failed", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, GetFileName().c_str());
return false;