From 3e741134279e02d204a8d4638f2d46dfbf814d0c Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 12 Sep 2014 23:18:02 +0100 Subject: Implemented Chest Minecarts --- src/UI/SlotArea.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/UI/SlotArea.cpp') diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index b4facb2d3..999bed989 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -10,6 +10,7 @@ #include "../BlockEntities/DropSpenserEntity.h" #include "../BlockEntities/EnderChestEntity.h" #include "../BlockEntities/FurnaceEntity.h" +#include "../Entities/Minecart.h" #include "../Items/ItemHandler.h" #include "Window.h" #include "../CraftingRecipes.h" @@ -1919,6 +1920,40 @@ void cSlotAreaFurnace::HandleSmeltItem(const cItem & a_Result, cPlayer & a_Playe +//////////////////////////////////////////////////////////////////////////////// +// cSlotAreaMinecartWithChest: + +cSlotAreaMinecartWithChest::cSlotAreaMinecartWithChest(cMinecartWithChest * a_Chest, cWindow & a_ParentWindow) : + cSlotArea(27, a_ParentWindow), + m_Chest(a_Chest) +{ +} + + + + + +const cItem * cSlotAreaMinecartWithChest::GetSlot(int a_SlotNum, cPlayer & a_Player) const +{ + // a_SlotNum ranges from 0 to 26, use that to index the minecart chest entity's inventory directly: + UNUSED(a_Player); + return &(m_Chest->GetSlot(a_SlotNum)); +} + + + + + +void cSlotAreaMinecartWithChest::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) +{ + UNUSED(a_Player); + m_Chest->SetSlot(a_SlotNum, a_Item); +} + + + + + //////////////////////////////////////////////////////////////////////////////// // cSlotAreaInventoryBase: -- cgit v1.2.3 From eeb580a74e48829908c303f8145802bfa1805c68 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Wed, 15 Oct 2014 19:01:55 +0200 Subject: Functions in cPluginManager get references instead of pointers. --- src/UI/SlotArea.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/UI/SlotArea.cpp') diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 999bed989..88d9f44fc 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -714,7 +714,7 @@ void cSlotAreaCrafting::UpdateRecipe(cPlayer & a_Player) { cCraftingGrid Grid(GetPlayerSlots(a_Player) + 1, m_GridSize, m_GridSize); cCraftingRecipe & Recipe = GetRecipeForPlayer(a_Player); - cRoot::Get()->GetCraftingRecipes()->GetRecipe(&a_Player, Grid, Recipe); + cRoot::Get()->GetCraftingRecipes()->GetRecipe(a_Player, Grid, Recipe); SetSlot(0, a_Player, Recipe.GetResult()); m_ParentWindow.SendSlot(a_Player, this, 0); } @@ -736,7 +736,7 @@ cCraftingRecipe & cSlotAreaCrafting::GetRecipeForPlayer(cPlayer & a_Player) // Not found. Add a new one: cCraftingGrid Grid(GetPlayerSlots(a_Player) + 1, m_GridSize, m_GridSize); cCraftingRecipe Recipe(Grid); - cRoot::Get()->GetCraftingRecipes()->GetRecipe(&a_Player, Grid, Recipe); + cRoot::Get()->GetCraftingRecipes()->GetRecipe(a_Player, Grid, Recipe); m_Recipes.push_back(std::make_pair(a_Player.GetUniqueID(), Recipe)); return m_Recipes.back().second; } -- cgit v1.2.3 From a26541a7c3ced0569098edd0aae61c097c2912f4 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 20 Oct 2014 21:55:07 +0100 Subject: En masse NULL -> nullptr replace --- src/UI/SlotArea.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'src/UI/SlotArea.cpp') diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 88d9f44fc..9113ec343 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -48,9 +48,9 @@ void cSlotArea::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickA ASSERT((a_SlotNum >= 0) && (a_SlotNum < GetNumSlots())); bool bAsync = false; - if (GetSlot(a_SlotNum, a_Player) == NULL) + if (GetSlot(a_SlotNum, a_Player) == nullptr) { - LOGWARNING("GetSlot(%d) returned NULL! Ignoring click", a_SlotNum); + LOGWARNING("GetSlot(%d) returned nullptr! Ignoring click", a_SlotNum); return; } @@ -791,9 +791,9 @@ void cSlotAreaAnvil::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_C } bool bAsync = false; - if (GetSlot(a_SlotNum, a_Player) == NULL) + if (GetSlot(a_SlotNum, a_Player) == nullptr) { - LOGWARNING("GetSlot(%d) returned NULL! Ignoring click", a_SlotNum); + LOGWARNING("GetSlot(%d) returned nullptr! Ignoring click", a_SlotNum); return; } @@ -980,7 +980,7 @@ void cSlotAreaAnvil::OnTakeResult(cPlayer & a_Player) m_ParentWindow.SetProperty(0, m_MaximumCost, a_Player); m_MaximumCost = 0; - ((cAnvilWindow*)&m_ParentWindow)->SetRepairedItemName("", NULL); + ((cAnvilWindow*)&m_ParentWindow)->SetRepairedItemName("", nullptr); int PosX, PosY, PosZ; ((cAnvilWindow*)&m_ParentWindow)->GetBlockPos(PosX, PosY, PosZ); @@ -1238,9 +1238,9 @@ void cSlotAreaBeacon::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ ASSERT((a_SlotNum >= 0) && (a_SlotNum < GetNumSlots())); bool bAsync = false; - if (GetSlot(a_SlotNum, a_Player) == NULL) + if (GetSlot(a_SlotNum, a_Player) == nullptr) { - LOGWARNING("GetSlot(%d) returned NULL! Ignoring click", a_SlotNum); + LOGWARNING("GetSlot(%d) returned nullptr! Ignoring click", a_SlotNum); return; } @@ -1408,9 +1408,9 @@ void cSlotAreaEnchanting::Clicked(cPlayer & a_Player, int a_SlotNum, eClickActio ASSERT((a_SlotNum >= 0) && (a_SlotNum < GetNumSlots())); bool bAsync = false; - if (GetSlot(a_SlotNum, a_Player) == NULL) + if (GetSlot(a_SlotNum, a_Player) == nullptr) { - LOGWARNING("GetSlot(%d) returned NULL! Ignoring click", a_SlotNum); + LOGWARNING("GetSlot(%d) returned nullptr! Ignoring click", a_SlotNum); return; } @@ -1709,19 +1709,19 @@ cSlotAreaFurnace::~cSlotAreaFurnace() void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) { - if (m_Furnace == NULL) + if (m_Furnace == nullptr) { - LOGERROR("cSlotAreaFurnace::Clicked(): m_Furnace == NULL"); - ASSERT(!"cSlotAreaFurnace::Clicked(): m_Furnace == NULL"); + LOGERROR("cSlotAreaFurnace::Clicked(): m_Furnace == nullptr"); + ASSERT(!"cSlotAreaFurnace::Clicked(): m_Furnace == nullptr"); return; } if (a_SlotNum == 2) { bool bAsync = false; - if (GetSlot(a_SlotNum, a_Player) == NULL) + if (GetSlot(a_SlotNum, a_Player) == nullptr) { - LOGWARNING("GetSlot(%d) returned NULL! Ignoring click", a_SlotNum); + LOGWARNING("GetSlot(%d) returned nullptr! Ignoring click", a_SlotNum); return; } @@ -2071,9 +2071,9 @@ void cSlotAreaArmor::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_C } bool bAsync = false; - if (GetSlot(a_SlotNum, a_Player) == NULL) + if (GetSlot(a_SlotNum, a_Player) == nullptr) { - LOGWARNING("GetSlot(%d) returned NULL! Ignoring click", a_SlotNum); + LOGWARNING("GetSlot(%d) returned nullptr! Ignoring click", a_SlotNum); return; } @@ -2223,15 +2223,15 @@ const cItem * cSlotAreaTemporary::GetSlot(int a_SlotNum, cPlayer & a_Player) con LOGERROR("cSlotAreaTemporary: player \"%s\" not found for slot %d!", a_Player.GetName().c_str(), a_SlotNum); ASSERT(!"cSlotAreaTemporary: player not found!"); - // Player not found, this should not happen, ever! Return NULL, but things may break by this. - return NULL; + // Player not found, this should not happen, ever! Return nullptr, but things may break by this. + return nullptr; } if (a_SlotNum >= (int)(itr->second.size())) { LOGERROR("cSlotAreaTemporary: asking for more slots than actually stored!"); ASSERT(!"cSlotAreaTemporary: asking for more slots than actually stored!"); - return NULL; + return nullptr; } return &(itr->second[a_SlotNum]); @@ -2320,7 +2320,7 @@ cItem * cSlotAreaTemporary::GetPlayerSlots(cPlayer & a_Player) cItemMap::iterator itr = m_Items.find(a_Player.GetUniqueID()); if (itr == m_Items.end()) { - return NULL; + return nullptr; } return &(itr->second[0]); } -- cgit v1.2.3