summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source/Protocol/Protocol17x.cpp25
-rw-r--r--source/Protocol/Protocol17x.h2
-rw-r--r--source/World.cpp57
3 files changed, 58 insertions, 26 deletions
diff --git a/source/Protocol/Protocol17x.cpp b/source/Protocol/Protocol17x.cpp
index b93a95e12..aef1cc8c2 100644
--- a/source/Protocol/Protocol17x.cpp
+++ b/source/Protocol/Protocol17x.cpp
@@ -103,6 +103,7 @@ void cProtocol172::HandlePacket(UInt32 a_PacketType, UInt32 a_RemainingBytes)
switch (a_PacketType)
{
case 0x00: HandlePacketStatusRequest(a_RemainingBytes); return;
+ case 0x01: HandlePacketStatusPing (a_RemainingBytes); return;
}
break;
}
@@ -157,6 +158,30 @@ void cProtocol172::HandlePacketStatusRequest(UInt32 a_RemainingBytes)
+void cProtocol172::HandlePacketStatusPing(UInt32 a_RemainingBytes)
+{
+ ASSERT(a_RemainingBytes == 8);
+ if (a_RemainingBytes != 8)
+ {
+ m_Client->PacketError(0x01);
+ m_ReceivedData.SkipRead(a_RemainingBytes);
+ m_ReceivedData.CommitRead();
+ return;
+ }
+ Int64 Timestamp;
+ m_ReceivedData.ReadBEInt64(Timestamp);
+ m_ReceivedData.CommitRead();
+
+ cByteBuffer Packet(18);
+ Packet.WriteVarInt(0x01);
+ Packet.WriteBEInt64(Timestamp);
+ WritePacket(Packet);
+}
+
+
+
+
+
void cProtocol172::WritePacket(cByteBuffer & a_Packet)
{
cCSLock Lock(m_CSPacket);
diff --git a/source/Protocol/Protocol17x.h b/source/Protocol/Protocol17x.h
index cea39f073..e5597ee0b 100644
--- a/source/Protocol/Protocol17x.h
+++ b/source/Protocol/Protocol17x.h
@@ -58,7 +58,9 @@ protected:
/// Reads and handles the packet. The packet length and type have already been read.
void HandlePacket(UInt32 a_PacketType, UInt32 a_RemainingBytes);
+ // Packet handlers while in the Status state (m_State == 1)
void HandlePacketStatusRequest(UInt32 a_RemainingBytes);
+ void HandlePacketStatusPing (UInt32 a_RemainingBytes);
/// Writes an entire packet into the output stream. a_Packet is expected to start with the packet type; data length is prepended here.
void WritePacket(cByteBuffer & a_Packet);
diff --git a/source/World.cpp b/source/World.cpp
index ad34dc6a5..dd3965e3d 100644
--- a/source/World.cpp
+++ b/source/World.cpp
@@ -55,6 +55,12 @@
/// Up to this many m_SpreadQueue elements are handled each world tick
const int MAX_LIGHTING_SPREAD_PER_TICK = 10;
+const int TIME_SUNSET = 12000;
+const int TIME_NIGHT_START = 13187;
+const int TIME_NIGHT_END = 22812;
+const int TIME_SUNRISE = 23999;
+const int TIME_SPAWN_DIVISOR = 148;
+
@@ -872,6 +878,31 @@ void cWorld::TickClients(float a_Dt)
+void cWorld::UpdateSkyDarkness(void)
+{
+ int TempTime = (int)m_TimeOfDay;
+ if (TempTime <= TIME_SUNSET)
+ {
+ m_SkyDarkness = 0;
+ }
+ else if (TempTime <= TIME_NIGHT_START)
+ {
+ m_SkyDarkness = (TIME_NIGHT_START - TempTime) / TIME_SPAWN_DIVISOR;
+ }
+ else if (TempTime <= TIME_NIGHT_END)
+ {
+ m_SkyDarkness = 8;
+ }
+ else
+ {
+ m_SkyDarkness = (TIME_SUNRISE - TempTime) / TIME_SPAWN_DIVISOR;
+ }
+}
+
+
+
+
+
void cWorld::WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ)
{
return m_ChunkMap->WakeUpSimulators(a_BlockX, a_BlockY, a_BlockZ);
@@ -2681,29 +2712,3 @@ void cWorld::cTaskSaveAllChunks::Run(cWorld & a_World)
-#define TIME_SUNSET 12000
-#define TIME_NIGHT_START 13187
-#define TIME_NIGHT_END 22812
-#define TIME_SUNRISE 23999
-#define TIME_SPAWN_DIVIZOR 148
-
-
-
-
-
-void cWorld::UpdateSkyDarkness()
-{
- int TempTime = m_TimeOfDay;
- if (TempTime <= TIME_SUNSET)
- m_SkyDarkness = 0;
- else if (TempTime <= TIME_NIGHT_START)
- m_SkyDarkness = (TIME_NIGHT_START - TempTime)/TIME_SPAWN_DIVIZOR;
- else if (TempTime <= TIME_NIGHT_END)
- m_SkyDarkness = 8;
- else
- m_SkyDarkness = (TIME_SUNRISE - TempTime)/TIME_SPAWN_DIVIZOR;
-}
-
-
-
-