diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-08-19 21:42:32 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-08-19 21:42:32 +0200 |
commit | 427e582d5fcbd5025a81a4e89ccada47877ccc64 (patch) | |
tree | 1196585a1a6fdc39c6a05aa117cfa2766f7dca2f /source/cChestEntity.cpp | |
parent | Android: Do not create an input thread for Android (diff) | |
download | cuberite-427e582d5fcbd5025a81a4e89ccada47877ccc64.tar cuberite-427e582d5fcbd5025a81a4e89ccada47877ccc64.tar.gz cuberite-427e582d5fcbd5025a81a4e89ccada47877ccc64.tar.bz2 cuberite-427e582d5fcbd5025a81a4e89ccada47877ccc64.tar.lz cuberite-427e582d5fcbd5025a81a4e89ccada47877ccc64.tar.xz cuberite-427e582d5fcbd5025a81a4e89ccada47877ccc64.tar.zst cuberite-427e582d5fcbd5025a81a4e89ccada47877ccc64.zip |
Diffstat (limited to '')
-rw-r--r-- | source/cChestEntity.cpp | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/source/cChestEntity.cpp b/source/cChestEntity.cpp index 5d015f42e..92a039dd7 100644 --- a/source/cChestEntity.cpp +++ b/source/cChestEntity.cpp @@ -184,13 +184,7 @@ void cChestEntity::UsedBy(cPlayer * a_Player) GetWindow()->SendWholeWindow( a_Player->GetClientHandle() ); } } - cPacket_BlockAction ChestOpen; - ChestOpen.m_PosX = GetPosX(); - ChestOpen.m_PosY = (short)GetPosY(); - ChestOpen.m_PosZ = GetPosZ(); - ChestOpen.m_Byte1 = (char)1; - ChestOpen.m_Byte2 = (char)1; - m_World->BroadcastToChunkOfBlock(m_PosX, m_PosY, m_PosZ, &ChestOpen); + m_World->BroadcastBlockAction(m_PosX, m_PosY, m_PosZ, 1, 1); // This is rather a hack // Instead of marking the chunk as dirty upon chest contents change, we mark it dirty now @@ -205,18 +199,18 @@ void cChestEntity::UsedBy(cPlayer * a_Player) -cItem *cChestEntity::GetContents(bool a_OnlyThis) +cItem * cChestEntity::GetContents(bool a_OnlyThis) { if (m_JoinedChest && !a_OnlyThis) { - cItem *Combined = new cItem[GetChestHeight()*c_ChestWidth]; - int i; - cItem *first = (m_TopChest) ? GetContents(true) : m_JoinedChest->GetContents(true); - cItem *second = (!m_TopChest) ? GetContents(true) : m_JoinedChest->GetContents(true); - for (i=0; i < GetChestHeight()*c_ChestWidth; i++) + // TODO: "Combined" memory leaks here + cItem * Combined = new cItem[GetChestHeight() * c_ChestWidth]; + cItem * first = (m_TopChest) ? GetContents(true) : m_JoinedChest->GetContents(true); + cItem * second = (!m_TopChest) ? GetContents(true) : m_JoinedChest->GetContents(true); + for (int i = 0; i < GetChestHeight() * c_ChestWidth; i++) { - int index = i % c_ChestHeight*c_ChestWidth; - if (i < c_ChestHeight*c_ChestWidth) + int index = i % (c_ChestHeight * c_ChestWidth); + if (i < c_ChestHeight * c_ChestWidth) Combined[index] = first[index]; else Combined[index] = second[index]; @@ -224,7 +218,9 @@ cItem *cChestEntity::GetContents(bool a_OnlyThis) return Combined; } else + { return m_Content; + } } |