summaryrefslogtreecommitdiffstats
path: root/src/Items
diff options
context:
space:
mode:
authorJulian Laubstein <julianlaubstein@yahoo.de>2015-07-29 18:45:36 +0200
committerJulian Laubstein <julianlaubstein@yahoo.de>2015-07-29 18:45:36 +0200
commit735d590abf7f804a4504b70c84a289ba86c5f8e3 (patch)
tree13b603c8bbf8177da92ce87f5413fb646d204f3f /src/Items
parentMerge pull request #2376 from mjhanninen/fix-freebsd-build (diff)
parentSilenced and fixed many warning messages across multiple files. (diff)
downloadcuberite-735d590abf7f804a4504b70c84a289ba86c5f8e3.tar
cuberite-735d590abf7f804a4504b70c84a289ba86c5f8e3.tar.gz
cuberite-735d590abf7f804a4504b70c84a289ba86c5f8e3.tar.bz2
cuberite-735d590abf7f804a4504b70c84a289ba86c5f8e3.tar.lz
cuberite-735d590abf7f804a4504b70c84a289ba86c5f8e3.tar.xz
cuberite-735d590abf7f804a4504b70c84a289ba86c5f8e3.tar.zst
cuberite-735d590abf7f804a4504b70c84a289ba86c5f8e3.zip
Diffstat (limited to 'src/Items')
-rw-r--r--src/Items/CMakeLists.txt2
-rw-r--r--src/Items/ItemEmptyMap.h2
-rw-r--r--src/Items/ItemFishingRod.h18
-rw-r--r--src/Items/ItemHandler.cpp5
-rw-r--r--src/Items/ItemLighter.h4
-rw-r--r--src/Items/ItemMap.h2
-rw-r--r--src/Items/ItemMinecart.h6
-rw-r--r--src/Items/ItemSlab.h2
-rw-r--r--src/Items/ItemSword.h5
9 files changed, 26 insertions, 20 deletions
diff --git a/src/Items/CMakeLists.txt b/src/Items/CMakeLists.txt
index 71f2d9ceb..46ff3b4a0 100644
--- a/src/Items/CMakeLists.txt
+++ b/src/Items/CMakeLists.txt
@@ -57,7 +57,7 @@ SET (HDRS
)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- set_source_files_properties(ItemHandler.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=conversion -Wno-error=old-style-cast -Wno-error=switch-enum")
+ set_source_files_properties(ItemHandler.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=conversion -Wno-error=switch-enum")
endif()
if(NOT MSVC)
diff --git a/src/Items/ItemEmptyMap.h b/src/Items/ItemEmptyMap.h
index 98352bd2d..f26f915c4 100644
--- a/src/Items/ItemEmptyMap.h
+++ b/src/Items/ItemEmptyMap.h
@@ -60,7 +60,7 @@ public:
return true;
}
- a_Player->GetInventory().AddItem(cItem(E_ITEM_MAP, 1, (short)(NewMap->GetID() & 0x7fff)));
+ a_Player->GetInventory().AddItem(cItem(E_ITEM_MAP, 1, static_cast<short>(NewMap->GetID() & 0x7fff)));
return true;
}
diff --git a/src/Items/ItemFishingRod.h b/src/Items/ItemFishingRod.h
index 5bf4b29b7..355ff2eae 100644
--- a/src/Items/ItemFishingRod.h
+++ b/src/Items/ItemFishingRod.h
@@ -27,27 +27,27 @@ class cFloaterCallback :
public:
cFloaterCallback(void) :
m_CanPickup(false),
- m_AttachedMobID(-1)
+ m_AttachedMobID(cEntity::INVALID_ID)
{
}
virtual bool Item(cEntity * a_Entity) override
{
- m_CanPickup = ((cFloater *)a_Entity)->CanPickup();
+ m_CanPickup = reinterpret_cast<cFloater *>(a_Entity)->CanPickup();
m_Pos = Vector3d(a_Entity->GetPosX(), a_Entity->GetPosY(), a_Entity->GetPosZ());
- m_AttachedMobID = ((cFloater *)a_Entity)->GetAttachedMobID();
+ m_AttachedMobID = reinterpret_cast<cFloater *>(a_Entity)->GetAttachedMobID();
a_Entity->Destroy(true);
return true;
}
bool CanPickup(void) const { return m_CanPickup; }
- bool IsAttached(void) const { return (m_AttachedMobID != -1); }
- int GetAttachedMobID(void) const { return m_AttachedMobID; }
+ bool IsAttached(void) const { return (m_AttachedMobID != cEntity::INVALID_ID); }
+ UInt32 GetAttachedMobID(void) const { return m_AttachedMobID; }
Vector3d GetPos(void) const { return m_Pos; }
protected:
bool m_CanPickup;
- int m_AttachedMobID;
+ UInt32 m_AttachedMobID;
Vector3d m_Pos;
} ;
@@ -137,7 +137,7 @@ public:
}
case 2:
{
- Drops.Add(cItem(E_ITEM_FISHING_ROD, 1, (short)a_World->GetTickRandomNumber(50))); // Fishing rod with durability. TODO: Enchantments on it
+ Drops.Add(cItem(E_ITEM_FISHING_ROD, 1, static_cast<short>(a_World->GetTickRandomNumber(50)))); // Fishing rod with durability. TODO: Enchantments on it
break;
}
case 3:
@@ -168,7 +168,7 @@ public:
}
else if (Junk <= 4)
{
- Drops.Add(cItem(E_ITEM_BOW, 1, (short)a_World->GetTickRandomNumber(64)));
+ Drops.Add(cItem(E_ITEM_BOW, 1, static_cast<short>(a_World->GetTickRandomNumber(64))));
}
else if (Junk <= 9)
{
@@ -244,7 +244,7 @@ public:
}
else
{
- cFloater * Floater = new cFloater(a_Player->GetPosX(), a_Player->GetStance(), a_Player->GetPosZ(), a_Player->GetLookVector() * 15, a_Player->GetUniqueID(), 100 + a_World->GetTickRandomNumber(800) - (a_Player->GetEquippedItem().m_Enchantments.GetLevel(cEnchantments::enchLure) * 100));
+ cFloater * Floater = new cFloater(a_Player->GetPosX(), a_Player->GetStance(), a_Player->GetPosZ(), a_Player->GetLookVector() * 15, a_Player->GetUniqueID(), static_cast<int>(100 + static_cast<unsigned int>(a_World->GetTickRandomNumber(800)) - (a_Player->GetEquippedItem().m_Enchantments.GetLevel(cEnchantments::enchLure) * 100)));
Floater->Initialize(*a_World);
a_Player->SetIsFishing(true, Floater->GetUniqueID());
}
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index aa5f6109b..580a0b7ee 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -531,12 +531,15 @@ void cItemHandler::OnFoodEaten(cWorld * a_World, cPlayer * a_Player, cItem * a_I
short cItemHandler::GetDurabilityLossByAction(eDurabilityLostAction a_Action)
{
- switch ((int)a_Action)
+ switch (a_Action)
{
case dlaAttackEntity: return 2;
case dlaBreakBlock: return 1;
}
+
+ #ifndef __clang__
return 0;
+ #endif
}
diff --git a/src/Items/ItemLighter.h b/src/Items/ItemLighter.h
index 24641dce6..a1b4b871b 100644
--- a/src/Items/ItemLighter.h
+++ b/src/Items/ItemLighter.h
@@ -57,7 +57,7 @@ public:
case E_BLOCK_TNT:
{
// Activate the TNT:
- a_World->BroadcastSoundEffect("game.tnt.primed", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 1.0f, 1.0f);
+ a_World->BroadcastSoundEffect("game.tnt.primed", static_cast<double>(a_BlockX), static_cast<double>(a_BlockY), static_cast<double>(a_BlockZ), 1.0f, 1.0f);
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
a_World->SpawnPrimedTNT(a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5); // 80 ticks to boom
break;
@@ -73,7 +73,7 @@ public:
if (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_AIR)
{
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FIRE, 0);
- a_World->BroadcastSoundEffect("fire.ignite", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 1.0F, 1.04F);
+ a_World->BroadcastSoundEffect("fire.ignite", static_cast<double>(a_BlockX), static_cast<double>(a_BlockY), static_cast<double>(a_BlockZ), 1.0F, 1.04F);
break;
}
}
diff --git a/src/Items/ItemMap.h b/src/Items/ItemMap.h
index a96183f41..19b974767 100644
--- a/src/Items/ItemMap.h
+++ b/src/Items/ItemMap.h
@@ -29,7 +29,7 @@ public:
virtual void OnUpdate(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item)
{
- cMap * Map = a_World->GetMapManager().GetMapData((unsigned)a_Item.m_ItemDamage);
+ cMap * Map = a_World->GetMapManager().GetMapData(static_cast<unsigned>(a_Item.m_ItemDamage));
if (Map == nullptr)
{
diff --git a/src/Items/ItemMinecart.h b/src/Items/ItemMinecart.h
index e7d2cf8cd..2cf42507b 100644
--- a/src/Items/ItemMinecart.h
+++ b/src/Items/ItemMinecart.h
@@ -56,9 +56,9 @@ public:
}
}
- double x = (double)a_BlockX + 0.5;
- double y = (double)a_BlockY + 0.5;
- double z = (double)a_BlockZ + 0.5;
+ double x = static_cast<double>(a_BlockX) + 0.5;
+ double y = static_cast<double>(a_BlockY) + 0.5;
+ double z = static_cast<double>(a_BlockZ) + 0.5;
cMinecart * Minecart = nullptr;
switch (m_ItemType)
{
diff --git a/src/Items/ItemSlab.h b/src/Items/ItemSlab.h
index 3a78cc016..21b53081a 100644
--- a/src/Items/ItemSlab.h
+++ b/src/Items/ItemSlab.h
@@ -40,7 +40,7 @@ public:
) override
{
// Prepare sound effect
- AString PlaceSound = cBlockInfo::GetPlaceSound(m_ItemType);
+ AString PlaceSound = cBlockInfo::GetPlaceSound(static_cast<BLOCKTYPE>(m_ItemType));
float Volume = 1.0f, Pitch = 0.8f;
// Special slab handling - placing a slab onto another slab produces a dblslab instead:
diff --git a/src/Items/ItemSword.h b/src/Items/ItemSword.h
index 2b2dbfc0d..3b0db7b21 100644
--- a/src/Items/ItemSword.h
+++ b/src/Items/ItemSword.h
@@ -46,12 +46,15 @@ public:
virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) override
{
- switch ((int)a_Action)
+ switch (a_Action)
{
case dlaAttackEntity: return 1;
case dlaBreakBlock: return 2;
}
+
+ #ifndef __clang__
return 0;
+ #endif
}
} ;