summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Chunk.cpp15
-rw-r--r--src/ChunkMap.cpp5
-rw-r--r--src/Entities/Player.cpp9
-rw-r--r--src/World.cpp13
-rw-r--r--src/World.h3
5 files changed, 20 insertions, 25 deletions
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index 4bf4557d9..c9bd1dbcf 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -684,21 +684,6 @@ void cChunk::SpawnMobs(cMobSpawner & a_MobSpawner)
void cChunk::Tick(std::chrono::milliseconds a_Dt)
{
- const auto ShouldTick = ShouldBeTicked();
-
- // If we are not valid, tick players and bailout
- if (!ShouldTick)
- {
- for (const auto & Entity : m_Entities)
- {
- if (Entity->IsPlayer())
- {
- Entity->Tick(a_Dt, *this);
- }
- }
- return;
- }
-
TickBlocks();
// Tick all block entities in this chunk:
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index 16e8fa267..7dd7901fd 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -1347,7 +1347,10 @@ void cChunkMap::Tick(std::chrono::milliseconds a_Dt)
// Do the magic of updating the world:
for (auto & Chunk : m_Chunks)
{
- Chunk.second.Tick(a_Dt);
+ if (Chunk.second.ShouldBeTicked())
+ {
+ Chunk.second.Tick(a_Dt);
+ }
}
// Finally, only after all chunks are ticked, tell the client about all aggregated changes:
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 04a7f9be0..9f4fcb971 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -3156,8 +3156,6 @@ void cPlayer::SpawnOn(cClientHandle & a_Client)
void cPlayer::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
- m_ClientHandle->Tick(a_Dt);
-
if (m_ClientHandle->IsDestroyed())
{
Destroy();
@@ -3182,13 +3180,6 @@ void cPlayer::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
}
}
- if (!a_Chunk.IsValid())
- {
- // Players are ticked even if the parent chunk is invalid.
- // We've processed as much as we can, bail:
- return;
- }
-
ASSERT((GetParentChunk() != nullptr) && (GetParentChunk()->IsValid()));
ASSERT(a_Chunk.IsValid());
diff --git a/src/World.cpp b/src/World.cpp
index 57ba656e8..1af7650e6 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -1033,6 +1033,7 @@ void cWorld::Tick(std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_La
Player->GetClientHandle()->ProcessProtocolIn();
}
+ TickClients(a_Dt);
TickQueuedChunkDataSets();
TickQueuedBlocks();
m_ChunkMap.Tick(a_Dt);
@@ -1072,6 +1073,18 @@ void cWorld::Tick(std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_La
+void cWorld::TickClients(const std::chrono::milliseconds a_Dt)
+{
+ for (const auto Player : m_Players)
+ {
+ Player->GetClientHandle()->Tick(a_Dt);
+ }
+}
+
+
+
+
+
void cWorld::TickWeather(float a_Dt)
{
UNUSED(a_Dt);
diff --git a/src/World.h b/src/World.h
index ea995ebdc..b6511edf5 100644
--- a/src/World.h
+++ b/src/World.h
@@ -1107,6 +1107,9 @@ private:
void Tick(std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec);
+ /** Ticks all clients that are in this world. */
+ void TickClients(std::chrono::milliseconds a_Dt);
+
/** Handles the weather in each tick */
void TickWeather(float a_Dt);