diff options
author | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2011-11-08 03:02:13 +0100 |
---|---|---|
committer | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2011-11-08 03:02:13 +0100 |
commit | 9ad53cde45fe6c4445a66b8ca969ec8b6025b3b1 (patch) | |
tree | efb1ba794c3c647690be34dabadae3899be6d082 | |
parent | Forgot to add squirrel project for windows (diff) | |
download | cuberite-9ad53cde45fe6c4445a66b8ca969ec8b6025b3b1.tar cuberite-9ad53cde45fe6c4445a66b8ca969ec8b6025b3b1.tar.gz cuberite-9ad53cde45fe6c4445a66b8ca969ec8b6025b3b1.tar.bz2 cuberite-9ad53cde45fe6c4445a66b8ca969ec8b6025b3b1.tar.lz cuberite-9ad53cde45fe6c4445a66b8ca969ec8b6025b3b1.tar.xz cuberite-9ad53cde45fe6c4445a66b8ca969ec8b6025b3b1.tar.zst cuberite-9ad53cde45fe6c4445a66b8ca969ec8b6025b3b1.zip |
-rw-r--r-- | Plugins/Core.lua | 4 | ||||
-rw-r--r-- | source/cWorld.cpp | 11 | ||||
-rw-r--r-- | source/cWorld.h | 3 |
3 files changed, 15 insertions, 3 deletions
diff --git a/Plugins/Core.lua b/Plugins/Core.lua index 4438401a9..5b98fcbaa 100644 --- a/Plugins/Core.lua +++ b/Plugins/Core.lua @@ -232,10 +232,10 @@ function HandleTimeCommand( Split, Player ) local Server = cRoot:Get():GetServer()
if( string.upper( Split[2] ) == "DAY") then
- cRoot:Get():GetWorld():SetWorldTime( 0 )
+ Player:GetWorld():SetWorldTime( 0 )
Server:SendMessage( cChatColor.Green .. Player:GetName() .. " set the time to Day.")
elseif( string.upper( Split[2] ) == "NIGHT") then
- cRoot:Get():GetWorld():SetWorldTime( 12000 + 1000 )
+ Player:GetWorld():SetWorldTime( 12000 + 1000 )
Server:SendMessage( cChatColor.Green .. Player:GetName() .. " set the time to Night.")
else
Player:SendMessage( cChatColor.Green .. "Usage: /time [Day/Night]" )
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();
|