Revert "Replace ItemCallbacks with lambdas (#3948)"
This reverts commit 496c337cdf.
This commit is contained in:
committed by
Alexander Harkness
parent
700bbdabf5
commit
49c443896d
@@ -138,18 +138,33 @@ bool cChestEntity::UsedBy(cPlayer * a_Player)
|
||||
void cChestEntity::ScanNeighbours()
|
||||
{
|
||||
// Callback for finding neighbouring chest:
|
||||
auto FindNeighbour = [this](cChestEntity & a_Chest)
|
||||
class cFindNeighbour :
|
||||
public cChestCallback
|
||||
{
|
||||
if (a_Chest.GetBlockType() != m_BlockType)
|
||||
public:
|
||||
cChestEntity * m_Neighbour;
|
||||
BLOCKTYPE m_ChestType;
|
||||
|
||||
cFindNeighbour(BLOCKTYPE a_ChestType) :
|
||||
m_Neighbour(nullptr),
|
||||
m_ChestType(a_ChestType)
|
||||
{
|
||||
// Neighboring block is not the same type of chest
|
||||
return true;
|
||||
}
|
||||
m_Neighbour = &a_Chest;
|
||||
return false;
|
||||
|
||||
virtual bool Item(cChestEntity * a_Chest) override
|
||||
{
|
||||
if (a_Chest->GetBlockType() != m_ChestType)
|
||||
{
|
||||
// Neighboring block is not the same type of chest
|
||||
return true;
|
||||
}
|
||||
m_Neighbour = a_Chest;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// Scan horizontally adjacent blocks for any neighbouring chest of the same type:
|
||||
cFindNeighbour FindNeighbour(m_BlockType);
|
||||
if (
|
||||
m_World->DoWithChestAt(m_PosX - 1, m_PosY, m_PosZ, FindNeighbour) ||
|
||||
m_World->DoWithChestAt(m_PosX + 1, m_PosY, m_PosZ, FindNeighbour) ||
|
||||
@@ -157,6 +172,7 @@ void cChestEntity::ScanNeighbours()
|
||||
m_World->DoWithChestAt(m_PosX, m_PosY, m_PosZ + 1, FindNeighbour)
|
||||
)
|
||||
{
|
||||
m_Neighbour = FindNeighbour.m_Neighbour;
|
||||
m_Neighbour->m_Neighbour = this;
|
||||
// Force neighbour's window shut. Does Mojang server do this or should a double window open?
|
||||
m_Neighbour->DestroyWindow();
|
||||
|
||||
Reference in New Issue
Block a user