1
0

Almost all packets' handling is now rewritten not to use cPacket descendants elsewhere than in cClientHandle.

git-svn-id: http://mc-server.googlecode.com/svn/trunk@761 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com
2012-08-19 19:42:32 +00:00
parent 5b36aa1567
commit 427e582d5f
40 changed files with 1089 additions and 507 deletions

View File

@@ -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;
}
}