summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/cWorld.cpp11
-rw-r--r--source/cWorld.h3
2 files changed, 13 insertions, 1 deletions
diff --git a/source/cWorld.cpp b/source/cWorld.cpp
index c80ccbe9f..f372eb69d 100644
--- a/source/cWorld.cpp
+++ b/source/cWorld.cpp
@@ -317,7 +317,7 @@ void cWorld::Tick(float a_Dt)
m_WorldTime %= 24000; // 24000 units in a day
bSendTime = true;
}
- if( bSendTime ) cRoot::Get()->GetServer()->Broadcast( cPacket_TimeUpdate( (m_WorldTime) ) );
+ if( bSendTime ) Broadcast( cPacket_TimeUpdate( (m_WorldTime) ) );
LockEntities();
for( cWorld::EntityList::iterator itr = GetEntities().begin(); itr != GetEntities().end();)
@@ -651,6 +651,15 @@ const double & cWorld::GetSpawnY()
return m_SpawnY;
}
+void cWorld::Broadcast( const cPacket & a_Packet, cClientHandle* a_Exclude /* = 0 */ )
+{
+ for( PlayerList::iterator itr = m_pState->m_Players.begin(); itr != m_pState->m_Players.end(); ++itr)
+ {
+ if( (*itr)->GetClientHandle() == a_Exclude || !(*itr)->GetClientHandle()->IsLoggedIn() ) continue;
+ (*itr)->GetClientHandle()->Send( a_Packet );
+ }
+}
+
void cWorld::AddPlayer( cPlayer* a_Player )
{
m_pState->m_Players.remove( a_Player );
diff --git a/source/cWorld.h b/source/cWorld.h
index e8ad0f517..10e181e48 100644
--- a/source/cWorld.h
+++ b/source/cWorld.h
@@ -8,6 +8,7 @@ enum ENUM_ITEM_ID;
#include <list>
+class cPacket;
class cWaterSimulator;
class cLavaSimulator;
class cChunkMap;
@@ -48,6 +49,8 @@ public:
//void RemoveClient( cClientHandle* a_Client );
//ClientList & GetClients();
+ void Broadcast( const cPacket & a_Packet, cClientHandle* a_Exclude = 0 );
+
void AddPlayer( cPlayer* a_Player );
void RemovePlayer( cPlayer* a_Player );
PlayerList & GetAllPlayers();