summaryrefslogtreecommitdiffstats
path: root/src/UI/Window.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2020-10-02 15:22:17 +0200
committerpeterbell10 <peterbell10@live.co.uk>2020-10-03 17:54:14 +0200
commit21068011c6d8a4794eec86794d6b9612a265f03a (patch)
treef8c6bf1d8760a02945c0622ff2d237ff3b737030 /src/UI/Window.cpp
parentFix instant mining of blocks not being recognised, tweak anti-cheat (#4938) (diff)
downloadcuberite-21068011c6d8a4794eec86794d6b9612a265f03a.tar
cuberite-21068011c6d8a4794eec86794d6b9612a265f03a.tar.gz
cuberite-21068011c6d8a4794eec86794d6b9612a265f03a.tar.bz2
cuberite-21068011c6d8a4794eec86794d6b9612a265f03a.tar.lz
cuberite-21068011c6d8a4794eec86794d6b9612a265f03a.tar.xz
cuberite-21068011c6d8a4794eec86794d6b9612a265f03a.tar.zst
cuberite-21068011c6d8a4794eec86794d6b9612a265f03a.zip
Diffstat (limited to 'src/UI/Window.cpp')
-rw-r--r--src/UI/Window.cpp150
1 files changed, 69 insertions, 81 deletions
diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp
index b59268ac4..07b84916d 100644
--- a/src/UI/Window.cpp
+++ b/src/UI/Window.cpp
@@ -347,6 +347,75 @@ bool cWindow::ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse)
+void cWindow::BroadcastSlot(cSlotArea * a_Area, int a_LocalSlotNum)
+{
+ // Translate local slot num into global slot num:
+ int SlotNum = 0;
+ bool HasFound = false;
+ for (cSlotAreas::const_iterator itr = m_SlotAreas.begin(), end = m_SlotAreas.end(); itr != end; ++itr)
+ {
+ if (a_Area == *itr)
+ {
+ SlotNum += a_LocalSlotNum;
+ HasFound = true;
+ break;
+ }
+ SlotNum += (*itr)->GetNumSlots();
+ } // for itr - m_SlotAreas[]
+ if (!HasFound)
+ {
+ LOGWARNING("%s: Invalid slot area parameter", __FUNCTION__);
+ ASSERT(!"Invalid slot area");
+ return;
+ }
+
+ // Broadcast the update packet:
+ cCSLock Lock(m_CS);
+ for (cPlayerList::iterator itr = m_OpenedBy.begin(); itr != m_OpenedBy.end(); ++itr)
+ {
+ (*itr)->GetClientHandle()->SendInventorySlot(m_WindowID, static_cast<short>(SlotNum), *a_Area->GetSlot(a_LocalSlotNum, **itr));
+ } // for itr - m_OpenedBy[]
+}
+
+
+
+
+
+void cWindow::SendWholeWindow(cClientHandle & a_Client)
+{
+ a_Client.SendWholeInventory(*this);
+}
+
+
+
+
+
+void cWindow::BroadcastWholeWindow(void)
+{
+ cCSLock Lock(m_CS);
+ for (auto Player : m_OpenedBy)
+ {
+ SendWholeWindow(*Player->GetClientHandle());
+ }
+}
+
+
+
+
+
+void cWindow::SetProperty(size_t a_Property, short a_Value)
+{
+ cCSLock Lock(m_CS);
+ for (auto Player : m_OpenedBy)
+ {
+ Player->GetClientHandle()->SendWindowProperty(*this, a_Property, a_Value);
+ }
+}
+
+
+
+
+
void cWindow::OwnerDestroyed()
{
m_Owner = nullptr;
@@ -685,84 +754,3 @@ int cWindow::DistributeItemToSlots(cPlayer & a_Player, const cItem & a_Item, int
} // for itr - SlotNums[]
return NumDistributed;
}
-
-
-
-
-
-void cWindow::BroadcastSlot(cSlotArea * a_Area, int a_LocalSlotNum)
-{
- // Translate local slot num into global slot num:
- int SlotNum = 0;
- bool HasFound = false;
- for (cSlotAreas::const_iterator itr = m_SlotAreas.begin(), end = m_SlotAreas.end(); itr != end; ++itr)
- {
- if (a_Area == *itr)
- {
- SlotNum += a_LocalSlotNum;
- HasFound = true;
- break;
- }
- SlotNum += (*itr)->GetNumSlots();
- } // for itr - m_SlotAreas[]
- if (!HasFound)
- {
- LOGWARNING("%s: Invalid slot area parameter", __FUNCTION__);
- ASSERT(!"Invalid slot area");
- return;
- }
-
- // Broadcast the update packet:
- cCSLock Lock(m_CS);
- for (cPlayerList::iterator itr = m_OpenedBy.begin(); itr != m_OpenedBy.end(); ++itr)
- {
- (*itr)->GetClientHandle()->SendInventorySlot(m_WindowID, static_cast<short>(SlotNum), *a_Area->GetSlot(a_LocalSlotNum, **itr));
- } // for itr - m_OpenedBy[]
-}
-
-
-
-
-
-void cWindow::SendWholeWindow(cClientHandle & a_Client)
-{
- a_Client.SendWholeInventory(*this);
-}
-
-
-
-
-
-void cWindow::BroadcastWholeWindow(void)
-{
- cCSLock Lock(m_CS);
- for (cPlayerList::iterator itr = m_OpenedBy.begin(); itr != m_OpenedBy.end(); ++itr)
- {
- SendWholeWindow(*(*itr)->GetClientHandle());
- } // for itr - m_OpenedBy[]
-}
-
-
-
-
-
-void cWindow::SetProperty(short a_Property, short a_Value)
-{
- cCSLock Lock(m_CS);
- for (cPlayerList::iterator itr = m_OpenedBy.begin(), end = m_OpenedBy.end(); itr != end; ++itr)
- {
- (*itr)->GetClientHandle()->SendWindowProperty(*this, a_Property, a_Value);
- } // for itr - m_OpenedBy[]
-}
-
-
-
-
-
-void cWindow::SetProperty(short a_Property, short a_Value, cPlayer & a_Player)
-{
- a_Player.GetClientHandle()->SendWindowProperty(*this, a_Property, a_Value);
-}
-
-
-