summaryrefslogtreecommitdiffstats
path: root/src/Items
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2016-12-19 21:12:23 +0100
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2017-08-07 20:24:16 +0200
commit4ef47aed62364f9cf1474864e5cf94232b4477af (patch)
tree28ca15247c2437b91e9aada48c2da4a1a3c00c17 /src/Items
parentRemoved unneeded includes (#3902) (diff)
downloadcuberite-4ef47aed62364f9cf1474864e5cf94232b4477af.tar
cuberite-4ef47aed62364f9cf1474864e5cf94232b4477af.tar.gz
cuberite-4ef47aed62364f9cf1474864e5cf94232b4477af.tar.bz2
cuberite-4ef47aed62364f9cf1474864e5cf94232b4477af.tar.lz
cuberite-4ef47aed62364f9cf1474864e5cf94232b4477af.tar.xz
cuberite-4ef47aed62364f9cf1474864e5cf94232b4477af.tar.zst
cuberite-4ef47aed62364f9cf1474864e5cf94232b4477af.zip
Diffstat (limited to '')
-rw-r--r--src/Items/ItemBoat.h5
-rw-r--r--src/Items/ItemBow.h11
-rw-r--r--src/Items/ItemFishingRod.h9
-rw-r--r--src/Items/ItemItemFrame.h7
-rw-r--r--src/Items/ItemMinecart.h19
-rw-r--r--src/Items/ItemPainting.h7
6 files changed, 16 insertions, 42 deletions
diff --git a/src/Items/ItemBoat.h b/src/Items/ItemBoat.h
index bdfed8944..f39a35a88 100644
--- a/src/Items/ItemBoat.h
+++ b/src/Items/ItemBoat.h
@@ -95,11 +95,8 @@ public:
}
// Spawn block at water level
- cBoat * Boat = new cBoat(x + 0.5, y + 0.5, z + 0.5, cBoat::ItemToMaterial(a_Player->GetEquippedItem()));
- if (!Boat->Initialize(*a_World))
+ if (a_World->SpawnBoat(x + 0.5, y + 0.5, z + 0.5, cBoat::ItemToMaterial(a_Player->GetEquippedItem())) == cEntity::INVALID_ID)
{
- delete Boat;
- Boat = nullptr;
return false;
}
diff --git a/src/Items/ItemBow.h b/src/Items/ItemBow.h
index a2f646efc..7cbd1dc70 100644
--- a/src/Items/ItemBow.h
+++ b/src/Items/ItemBow.h
@@ -69,17 +69,12 @@ public:
}
// Create the arrow entity:
- cArrowEntity * Arrow = new cArrowEntity(*a_Player, Force * 2);
- if (Arrow == nullptr)
+ auto Arrow = cpp14::make_unique<cArrowEntity>(*a_Player, Force * 2);
+ auto ArrowPtr = Arrow.get();
+ if (!ArrowPtr->Initialize(std::move(Arrow), *a_Player->GetWorld()))
{
return;
}
- if (!Arrow->Initialize(*a_Player->GetWorld()))
- {
- delete Arrow;
- Arrow = nullptr;
- return;
- }
a_Player->GetWorld()->BroadcastSoundEffect(
"entity.arrow.shoot",
a_Player->GetPosX(),
diff --git a/src/Items/ItemFishingRod.h b/src/Items/ItemFishingRod.h
index a32368304..012f13a6c 100644
--- a/src/Items/ItemFishingRod.h
+++ b/src/Items/ItemFishingRod.h
@@ -251,14 +251,13 @@ public:
}
else
{
- cFloater * Floater = new cFloater(a_Player->GetPosX(), a_Player->GetStance(), a_Player->GetPosZ(), a_Player->GetLookVector() * 15, a_Player->GetUniqueID(), (Random.RandInt(100, 900) - static_cast<int>(a_Player->GetEquippedItem().m_Enchantments.GetLevel(cEnchantments::enchLure) * 100)));
- if (!Floater->Initialize(*a_World))
+ auto Floater = cpp14::make_unique<cFloater>(a_Player->GetPosX(), a_Player->GetStance(), a_Player->GetPosZ(), a_Player->GetLookVector() * 15, a_Player->GetUniqueID(), (Random.RandInt(100, 900) - static_cast<int>(a_Player->GetEquippedItem().m_Enchantments.GetLevel(cEnchantments::enchLure) * 100)));
+ auto FloaterPtr = Floater.get();
+ if (!FloaterPtr->Initialize(std::move(Floater), *a_World))
{
- delete Floater;
- Floater = nullptr;
return false;
}
- a_Player->SetIsFishing(true, Floater->GetUniqueID());
+ a_Player->SetIsFishing(true, FloaterPtr->GetUniqueID());
}
return true;
}
diff --git a/src/Items/ItemItemFrame.h b/src/Items/ItemItemFrame.h
index 77a5bf47c..dd3e1f5a8 100644
--- a/src/Items/ItemItemFrame.h
+++ b/src/Items/ItemItemFrame.h
@@ -38,11 +38,10 @@ public:
if (Block == E_BLOCK_AIR)
{
- cItemFrame * ItemFrame = new cItemFrame(a_BlockFace, a_BlockX, a_BlockY, a_BlockZ);
- if (!ItemFrame->Initialize(*a_World))
+ auto ItemFrame = cpp14::make_unique<cItemFrame>(a_BlockFace, a_BlockX, a_BlockY, a_BlockZ);
+ auto ItemFramePtr = ItemFrame.get();
+ if (!ItemFramePtr->Initialize(std::move(ItemFrame), *a_World))
{
- delete ItemFrame;
- ItemFrame = nullptr;
return false;
}
diff --git a/src/Items/ItemMinecart.h b/src/Items/ItemMinecart.h
index 623342d41..05f375f06 100644
--- a/src/Items/ItemMinecart.h
+++ b/src/Items/ItemMinecart.h
@@ -59,24 +59,9 @@ public:
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)
- {
- case E_ITEM_MINECART: Minecart = new cRideableMinecart (x, y, z, cItem(), 1); break;
- case E_ITEM_CHEST_MINECART: Minecart = new cMinecartWithChest (x, y, z); break;
- case E_ITEM_FURNACE_MINECART: Minecart = new cMinecartWithFurnace (x, y, z); break;
- case E_ITEM_MINECART_WITH_TNT: Minecart = new cMinecartWithTNT (x, y, z); break;
- case E_ITEM_MINECART_WITH_HOPPER: Minecart = new cMinecartWithHopper (x, y, z); break;
- default:
- {
- ASSERT(!"Unhandled minecart item");
- return false;
- }
- } // switch (m_ItemType)
- if (!Minecart->Initialize(*a_World))
+
+ if (a_World->SpawnMinecart(x, y, z, m_ItemType) == cEntity::INVALID_ID)
{
- delete Minecart;
- Minecart = nullptr;
return false;
}
diff --git a/src/Items/ItemPainting.h b/src/Items/ItemPainting.h
index 3432583ca..8e5a1b5d2 100644
--- a/src/Items/ItemPainting.h
+++ b/src/Items/ItemPainting.h
@@ -70,11 +70,10 @@ public:
{ "BurningSkull" }
};
- cPainting * Painting = new cPainting(gPaintingTitlesList[a_World->GetTickRandomNumber(ARRAYCOUNT(gPaintingTitlesList) - 1)].Title, a_BlockFace, a_BlockX, a_BlockY, a_BlockZ);
- if (!Painting->Initialize(*a_World))
+ auto Painting = cpp14::make_unique<cPainting>(gPaintingTitlesList[a_World->GetTickRandomNumber(ARRAYCOUNT(gPaintingTitlesList) - 1)].Title, a_BlockFace, a_BlockX, a_BlockY, a_BlockZ);
+ auto PaintingPtr = Painting.get();
+ if (!PaintingPtr->Initialize(std::move(Painting), *a_World))
{
- delete Painting;
- Painting = nullptr;
return false;
}