From 3daf253b7f4ed8243e3262faee35219335e3e088 Mon Sep 17 00:00:00 2001 From: 12xx12 <44411062+12xx12@users.noreply.github.com> Date: Sun, 7 Mar 2021 17:31:43 +0100 Subject: Some emplace_back replacements (#5149) * replace push_back with emplace_back when a new object was created in the function call --- src/Mobs/Chicken.cpp | 2 +- src/Mobs/Monster.cpp | 2 +- src/Mobs/Mooshroom.cpp | 2 +- src/Mobs/Pig.cpp | 2 +- src/Mobs/Sheep.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/Mobs') diff --git a/src/Mobs/Chicken.cpp b/src/Mobs/Chicken.cpp index 71bd80af4..eacbd482d 100644 --- a/src/Mobs/Chicken.cpp +++ b/src/Mobs/Chicken.cpp @@ -40,7 +40,7 @@ void cChicken::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { cItems Drops; m_EggDropTimer = 0; - Drops.push_back(cItem(E_ITEM_EGG, 1)); + Drops.emplace_back(E_ITEM_EGG, 1); m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); } else diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index b115b241a..237c50524 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -1521,7 +1521,7 @@ void cMonster::AddRandomUncommonDropItem(cItems & a_Drops, float a_Chance, short { if (GetRandomProvider().RandBool(a_Chance / 100.0)) { - a_Drops.push_back(cItem(a_Item, 1, a_ItemHealth)); + a_Drops.emplace_back(a_Item, 1, a_ItemHealth); } } diff --git a/src/Mobs/Mooshroom.cpp b/src/Mobs/Mooshroom.cpp index 1190f46e9..6318cdef2 100644 --- a/src/Mobs/Mooshroom.cpp +++ b/src/Mobs/Mooshroom.cpp @@ -65,7 +65,7 @@ void cMooshroom::OnRightClicked(cPlayer & a_Player) } cItems Drops; - Drops.push_back(cItem(E_BLOCK_RED_MUSHROOM, 5, 0)); + Drops.emplace_back(E_BLOCK_RED_MUSHROOM, 5, 0); m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); m_World->SpawnMob(GetPosX(), GetPosY(), GetPosZ(), mtCow, false); Destroy(); diff --git a/src/Mobs/Pig.cpp b/src/Mobs/Pig.cpp index 1e531aebd..2bcb94f2b 100644 --- a/src/Mobs/Pig.cpp +++ b/src/Mobs/Pig.cpp @@ -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.push_back(cItem(E_ITEM_SADDLE, 1)); + a_Drops.emplace_back(E_ITEM_SADDLE, 1); } } diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp index 7bcfe1836..e208420db 100644 --- a/src/Mobs/Sheep.cpp +++ b/src/Mobs/Sheep.cpp @@ -42,7 +42,7 @@ void cSheep::GetDrops(cItems & a_Drops, cEntity * a_Killer) if (!m_IsSheared) { - a_Drops.push_back(cItem(E_BLOCK_WOOL, 1, static_cast(m_WoolColor))); + a_Drops.emplace_back(E_BLOCK_WOOL, 1, static_cast(m_WoolColor)); } unsigned int LootingLevel = 0; -- cgit v1.2.3