1
0

Rewritten most of the code for multithreading; still not 100%, but getting there. If this commit proves to be too problematic, we can always undo it.

git-svn-id: http://mc-server.googlecode.com/svn/trunk@251 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com
2012-02-13 21:47:03 +00:00
parent 0a46c065bf
commit 4f17362aeb
87 changed files with 6915 additions and 2803 deletions

View File

@@ -23,14 +23,18 @@ class cRoot;
cChestEntity::cChestEntity(int a_X, int a_Y, int a_Z, cChunk* a_Chunk)
: cBlockEntity( E_BLOCK_CHEST, a_X, a_Y, a_Z, a_Chunk )
cChestEntity::cChestEntity(int a_X, int a_Y, int a_Z, cWorld * a_World)
: cBlockEntity( E_BLOCK_CHEST, a_X, a_Y, a_Z, a_World)
, m_TopChest( false )
, m_JoinedChest( 0 )
, m_JoinedChest( NULL )
{
m_Content = new cItem[ c_ChestHeight*c_ChestWidth ];
}
cChestEntity::~cChestEntity()
{
if( GetWindow() )
@@ -44,6 +48,10 @@ cChestEntity::~cChestEntity()
}
}
void cChestEntity::Destroy()
{
// Drop items
@@ -51,15 +59,21 @@ void cChestEntity::Destroy()
{
if( !m_Content[i].IsEmpty() )
{
cPickup* Pickup = new cPickup( m_PosX*32 + 16, m_PosY*32 + 16, m_PosZ*32 + 16, m_Content[i], 0, 1.f, 0 );
Pickup->Initialize( GetChunk()->GetWorld() );
cPickup * Pickup = new cPickup( m_PosX * 32 + 16, m_PosY * 32 + 16, m_PosZ * 32 + 16, m_Content[i], 0, 1.f, 0 );
Pickup->Initialize(m_World);
m_Content[i].Empty();
}
}
if (m_JoinedChest)
{
m_JoinedChest->RemoveJoinedChest(this);
}
}
cItem * cChestEntity::GetSlot( int a_Slot )
{
if( a_Slot > -1 && a_Slot < c_ChestHeight*c_ChestWidth )
@@ -69,6 +83,10 @@ cItem * cChestEntity::GetSlot( int a_Slot )
return 0;
}
void cChestEntity::SetSlot( int a_Slot, cItem & a_Item )
{
if( a_Slot > -1 && a_Slot < c_ChestHeight*c_ChestWidth )
@@ -129,6 +147,10 @@ bool cChestEntity::LoadFromJson( const Json::Value& a_Value )
return true;
}
void cChestEntity::SaveToJson( Json::Value& a_Value )
{
a_Value["x"] = m_PosX;
@@ -147,6 +169,10 @@ void cChestEntity::SaveToJson( Json::Value& a_Value )
a_Value["Slots"] = AllSlots;
}
void cChestEntity::SendTo( cClientHandle* a_Client, cServer* a_Server )
{
(void)a_Client;
@@ -154,6 +180,10 @@ void cChestEntity::SendTo( cClientHandle* a_Client, cServer* a_Server )
return;
}
void cChestEntity::UsedBy( cPlayer & a_Player )
{
LOG("Used a chest");
@@ -185,15 +215,13 @@ void cChestEntity::UsedBy( cPlayer & a_Player )
ChestOpen.m_PosZ = GetPosZ();
ChestOpen.m_Byte1 = (char)1;
ChestOpen.m_Byte2 = (char)1;
cWorld::PlayerList PlayerList = cRoot::Get()->GetWorld()->GetAllPlayers();
for( cWorld::PlayerList::iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr )
{
if ((*itr) && (*itr)->GetClientHandle() && !((*itr)->GetClientHandle()->IsDestroyed())) {
(*itr)->GetClientHandle()->Send( ChestOpen );
}
}
m_World->GetChunkOfBlock(m_PosX, m_PosY, m_PosZ)->Broadcast(&ChestOpen);
}
cItem *cChestEntity::GetContents(bool a_OnlyThis)
{
if (m_JoinedChest && !a_OnlyThis)
@@ -215,3 +243,7 @@ cItem *cChestEntity::GetContents(bool a_OnlyThis)
else
return m_Content;
}