summaryrefslogtreecommitdiffstats
path: root/src/Items
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2016-12-18 21:41:37 +0100
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2016-12-18 21:41:37 +0100
commitb5b119ca750a1790848b514bb00831b050f25fac (patch)
treee7a145a856676d248da5050b57da1cee4d005815 /src/Items
parenttest (diff)
downloadcuberite-b5b119ca750a1790848b514bb00831b050f25fac.tar
cuberite-b5b119ca750a1790848b514bb00831b050f25fac.tar.gz
cuberite-b5b119ca750a1790848b514bb00831b050f25fac.tar.bz2
cuberite-b5b119ca750a1790848b514bb00831b050f25fac.tar.lz
cuberite-b5b119ca750a1790848b514bb00831b050f25fac.tar.xz
cuberite-b5b119ca750a1790848b514bb00831b050f25fac.tar.zst
cuberite-b5b119ca750a1790848b514bb00831b050f25fac.zip
Diffstat (limited to 'src/Items')
-rw-r--r--src/Items/ItemBoat.h3
-rw-r--r--src/Items/ItemBow.h11
-rw-r--r--src/Items/ItemFishingRod.h4
-rw-r--r--src/Items/ItemItemFrame.h6
-rw-r--r--src/Items/ItemMinecart.h17
-rw-r--r--src/Items/ItemPainting.h4
6 files changed, 12 insertions, 33 deletions
diff --git a/src/Items/ItemBoat.h b/src/Items/ItemBoat.h
index de16c70dc..ad6934916 100644
--- a/src/Items/ItemBoat.h
+++ b/src/Items/ItemBoat.h
@@ -92,8 +92,7 @@ public:
}
// Spawn block at water level
- cBoat * Boat = new cBoat(x + 0.5, y + 0.5, z + 0.5);
- Boat->Initialize(*a_World);
+ a_World->SpawnBoat(x + 0.5, y + 0.5, z + 0.5);
return true;
}
diff --git a/src/Items/ItemBow.h b/src/Items/ItemBow.h
index fc0ee8434..0d4bdd46e 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 ArrowPtr = cpp14::make_unique<cArrowEntity>(*a_Player, Force * 2);
+ auto Arrow = ArrowPtr.get();
+ if (!Arrow->Initialize(std::move(ArrowPtr), *a_Player->GetWorld()))
{
return;
}
- if (!Arrow->Initialize(*a_Player->GetWorld()))
- {
- delete Arrow;
- Arrow = nullptr;
- return;
- }
a_Player->GetWorld()->BroadcastSoundEffect(
"random.bow",
a_Player->GetPosX(),
diff --git a/src/Items/ItemFishingRod.h b/src/Items/ItemFishingRod.h
index 3a2ef0275..e44eb09bb 100644
--- a/src/Items/ItemFishingRod.h
+++ b/src/Items/ItemFishingRod.h
@@ -244,9 +244,9 @@ public:
}
else
{
- 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);
+ auto Floater = cpp14::make_unique<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)));
a_Player->SetIsFishing(true, Floater->GetUniqueID());
+ Floater->Initialize(std::move(Floater), *a_World);
}
return true;
}
diff --git a/src/Items/ItemItemFrame.h b/src/Items/ItemItemFrame.h
index 77a5bf47c..a670d6cac 100644
--- a/src/Items/ItemItemFrame.h
+++ b/src/Items/ItemItemFrame.h
@@ -38,11 +38,9 @@ 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);
+ if (!ItemFrame->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 6344c0178..d7ea18719 100644
--- a/src/Items/ItemMinecart.h
+++ b/src/Items/ItemMinecart.h
@@ -59,21 +59,8 @@ 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)
- Minecart->Initialize(*a_World);
+
+ a_World->SpawnMinecart(x, y, z, m_ItemType);
if (!a_Player->IsGameModeCreative())
{
diff --git a/src/Items/ItemPainting.h b/src/Items/ItemPainting.h
index dd35931dd..60a231d2b 100644
--- a/src/Items/ItemPainting.h
+++ b/src/Items/ItemPainting.h
@@ -70,8 +70,8 @@ public:
{ "BurningSkull" }
};
- cPainting * Painting = new cPainting(gPaintingTitlesList[a_World->GetTickRandomNumber(ARRAYCOUNT(gPaintingTitlesList) - 1)].Title, a_BlockFace, a_BlockX, a_BlockY, a_BlockZ);
- 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);
+ Painting->Initialize(std::move(Painting), *a_World);
if (!a_Player->IsGameModeCreative())
{