From e92b9e7ecbdf2918aab59d4eeb7bb5966430b264 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Fri, 24 Aug 2012 07:58:26 +0000 Subject: Monster classes don't use cPackets. Chat messages are sent / broadcast without cPackets. BlockEntities don't use cPackets. git-svn-id: http://mc-server.googlecode.com/svn/trunk@783 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cEntity.cpp | 47 ++++++++--------------------------------------- 1 file changed, 8 insertions(+), 39 deletions(-) (limited to 'source/cEntity.cpp') diff --git a/source/cEntity.cpp b/source/cEntity.cpp index a906737cf..12af1c0b7 100644 --- a/source/cEntity.cpp +++ b/source/cEntity.cpp @@ -68,7 +68,13 @@ cEntity::~cEntity() -void cEntity::Initialize( cWorld* a_World ) +CLASS_DEF_GETCLASS(cEntity); + + + + + +void cEntity::Initialize(cWorld * a_World) { m_World = a_World; m_World->AddEntity( this ); @@ -118,31 +124,17 @@ void cEntity::MoveToCorrectChunk(bool a_bIgnoreOldChunk) virtual void Added(cClientHandle * a_Client) override { - if (m_Spawn == NULL) - { - m_Spawn = m_Entity->GetSpawnPacket(); // Only create the packet when needed - } - if (m_Spawn != NULL) - { - a_Client->Send(*m_Spawn); - } + m_Entity->SpawnOn(*a_Client); } - cPacket * m_Spawn; bool m_IgnoreOldChunk; cEntity * m_Entity; public: cMover(cEntity * a_Entity, bool a_IgnoreOldChunk) : - m_Spawn(NULL), m_IgnoreOldChunk(a_IgnoreOldChunk), m_Entity(a_Entity) {} - - ~cMover() - { - delete m_Spawn; - } } Mover(this, a_bIgnoreOldChunk); m_World->CompareChunkClients(m_ChunkX, m_ChunkY, m_ChunkZ, ChunkX, ChunkY, ChunkZ, Mover); @@ -194,29 +186,6 @@ void cEntity::RemoveFromChunk(void) -void cEntity::SpawnOn(cClientHandle * a_Client) -{ - std::auto_ptr SpawnPacket(GetSpawnPacket()); - if (SpawnPacket.get() == NULL) - { - return; - } - - if (a_Client == NULL) - { - m_World->BroadcastToChunk(m_ChunkX, m_ChunkY, m_ChunkZ, *SpawnPacket.get(), NULL); - } - else - { - a_Client->Send(*(SpawnPacket.get())); - } -} - - - - - -CLASS_DEF_GETCLASS( cEntity ); bool cEntity::IsA( const char* a_EntityType ) { //LOG("IsA( cEntity ) : %s", a_EntityType); -- cgit v1.2.3