summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Bindings/LuaState.cpp7
-rw-r--r--src/Bindings/LuaState.h1
-rw-r--r--src/Bindings/Plugin.h2
-rw-r--r--src/Bindings/PluginLua.cpp2
-rw-r--r--src/Bindings/PluginLua.h2
-rw-r--r--src/Bindings/PluginManager.cpp2
-rw-r--r--src/Bindings/PluginManager.h2
-rw-r--r--src/BlockEntities/BeaconEntity.cpp2
-rw-r--r--src/BlockEntities/BeaconEntity.h2
-rw-r--r--src/BlockEntities/BlockEntity.h2
-rw-r--r--src/BlockEntities/CommandBlockEntity.cpp2
-rw-r--r--src/BlockEntities/CommandBlockEntity.h2
-rw-r--r--src/BlockEntities/DropSpenserEntity.cpp2
-rw-r--r--src/BlockEntities/DropSpenserEntity.h2
-rw-r--r--src/BlockEntities/FurnaceEntity.cpp2
-rw-r--r--src/BlockEntities/FurnaceEntity.h2
-rw-r--r--src/BlockEntities/HopperEntity.cpp2
-rw-r--r--src/BlockEntities/HopperEntity.h2
-rw-r--r--src/BlockEntities/MobSpawnerEntity.cpp2
-rw-r--r--src/BlockEntities/MobSpawnerEntity.h2
-rw-r--r--src/Chunk.cpp2
-rw-r--r--src/Chunk.h2
-rw-r--r--src/ChunkMap.cpp4
-rw-r--r--src/ChunkMap.h4
-rw-r--r--src/Entities/ArrowEntity.cpp6
-rw-r--r--src/Entities/ArrowEntity.h2
-rw-r--r--src/Entities/Boat.cpp2
-rw-r--r--src/Entities/Boat.h2
-rw-r--r--src/Entities/EnderCrystal.cpp2
-rw-r--r--src/Entities/EnderCrystal.h2
-rw-r--r--src/Entities/Entity.cpp26
-rw-r--r--src/Entities/Entity.h4
-rw-r--r--src/Entities/ExpOrb.cpp4
-rw-r--r--src/Entities/ExpOrb.h2
-rw-r--r--src/Entities/FallingBlock.cpp4
-rw-r--r--src/Entities/FallingBlock.h2
-rw-r--r--src/Entities/FireworkEntity.cpp8
-rw-r--r--src/Entities/FireworkEntity.h4
-rw-r--r--src/Entities/Floater.cpp2
-rw-r--r--src/Entities/Floater.h2
-rw-r--r--src/Entities/HangingEntity.h2
-rw-r--r--src/Entities/Minecart.cpp10
-rw-r--r--src/Entities/Minecart.h4
-rw-r--r--src/Entities/Painting.cpp2
-rw-r--r--src/Entities/Painting.h2
-rw-r--r--src/Entities/Pawn.cpp2
-rw-r--r--src/Entities/Pawn.h2
-rw-r--r--src/Entities/Pickup.cpp6
-rw-r--r--src/Entities/Pickup.h2
-rw-r--r--src/Entities/Player.cpp2
-rw-r--r--src/Entities/Player.h4
-rw-r--r--src/Entities/ProjectileEntity.cpp4
-rw-r--r--src/Entities/ProjectileEntity.h4
-rw-r--r--src/Entities/SplashPotionEntity.h2
-rw-r--r--src/Entities/TNTEntity.cpp2
-rw-r--r--src/Entities/TNTEntity.h2
-rw-r--r--src/Entities/ThrownEggEntity.cpp2
-rw-r--r--src/Entities/ThrownEggEntity.h2
-rw-r--r--src/Entities/ThrownEnderPearlEntity.cpp2
-rw-r--r--src/Entities/ThrownEnderPearlEntity.h2
-rw-r--r--src/Entities/ThrownSnowballEntity.cpp2
-rw-r--r--src/Entities/ThrownSnowballEntity.h2
-rw-r--r--src/Globals.h1
-rw-r--r--src/Mobs/AggressiveMonster.cpp6
-rw-r--r--src/Mobs/AggressiveMonster.h4
-rw-r--r--src/Mobs/Blaze.cpp4
-rw-r--r--src/Mobs/Blaze.h2
-rw-r--r--src/Mobs/CaveSpider.cpp4
-rw-r--r--src/Mobs/CaveSpider.h4
-rw-r--r--src/Mobs/Chicken.cpp2
-rw-r--r--src/Mobs/Chicken.h2
-rw-r--r--src/Mobs/Creeper.cpp4
-rw-r--r--src/Mobs/Creeper.h4
-rw-r--r--src/Mobs/Enderman.cpp2
-rw-r--r--src/Mobs/Enderman.h2
-rw-r--r--src/Mobs/Ghast.cpp4
-rw-r--r--src/Mobs/Ghast.h2
-rw-r--r--src/Mobs/Guardian.cpp2
-rw-r--r--src/Mobs/Guardian.h2
-rw-r--r--src/Mobs/Horse.cpp2
-rw-r--r--src/Mobs/Horse.h2
-rw-r--r--src/Mobs/Monster.cpp12
-rw-r--r--src/Mobs/Monster.h2
-rw-r--r--src/Mobs/PassiveMonster.cpp2
-rw-r--r--src/Mobs/PassiveMonster.h2
-rw-r--r--src/Mobs/Pig.cpp2
-rw-r--r--src/Mobs/Pig.h2
-rw-r--r--src/Mobs/Sheep.cpp2
-rw-r--r--src/Mobs/Sheep.h2
-rw-r--r--src/Mobs/Skeleton.cpp4
-rw-r--r--src/Mobs/Skeleton.h2
-rw-r--r--src/Mobs/Slime.cpp2
-rw-r--r--src/Mobs/Slime.h2
-rw-r--r--src/Mobs/SnowGolem.cpp2
-rw-r--r--src/Mobs/SnowGolem.h2
-rw-r--r--src/Mobs/Squid.cpp2
-rw-r--r--src/Mobs/Squid.h2
-rw-r--r--src/Mobs/Villager.cpp2
-rw-r--r--src/Mobs/Villager.h2
-rw-r--r--src/Mobs/Wither.cpp2
-rw-r--r--src/Mobs/Wither.h2
-rw-r--r--src/Mobs/Wolf.cpp4
-rw-r--r--src/Mobs/Wolf.h4
-rw-r--r--src/Simulator/DelayedFluidSimulator.cpp2
-rw-r--r--src/Simulator/DelayedFluidSimulator.h2
-rw-r--r--src/Simulator/FireSimulator.cpp4
-rw-r--r--src/Simulator/FireSimulator.h2
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator.cpp2
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator.h2
-rw-r--r--src/Simulator/NoopRedstoneSimulator.h2
-rw-r--r--src/Simulator/SandSimulator.cpp2
-rw-r--r--src/Simulator/SandSimulator.h2
-rw-r--r--src/Simulator/Simulator.h2
-rw-r--r--src/Simulator/SimulatorManager.cpp2
-rw-r--r--src/Simulator/SimulatorManager.h2
-rw-r--r--src/World.cpp79
-rw-r--r--src/World.h28
117 files changed, 221 insertions, 221 deletions
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index 2f5d173fd..4bc9906ee 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -839,6 +839,13 @@ void cLuaState::Push(void * a_Ptr)
m_NumCurrentFunctionArgs += 1;
}
+void cLuaState::Push(std::chrono::milliseconds a_Value)
+{
+ ASSERT(IsValid());
+
+ tolua_pushnumber(m_LuaState, a_Value.count());
+ m_NumCurrentFunctionArgs += 1;
+}
diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h
index c13e36188..7ac4120e1 100644
--- a/src/Bindings/LuaState.h
+++ b/src/Bindings/LuaState.h
@@ -217,6 +217,7 @@ public:
void Push(Vector3d * a_Vector);
void Push(Vector3i * a_Vector);
void Push(void * a_Ptr);
+ void Push(std::chrono::milliseconds a_time);
/** Retrieve value at a_StackPos, if it is a valid bool. If not, a_Value is unchanged */
void GetStackValue(int a_StackPos, bool & a_Value);
diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h
index b5944e9cb..6210dbed4 100644
--- a/src/Bindings/Plugin.h
+++ b/src/Bindings/Plugin.h
@@ -104,7 +104,7 @@ public:
virtual bool OnWeatherChanged (cWorld & a_World) = 0;
virtual bool OnWeatherChanging (cWorld & a_World, eWeather & a_NewWeather) = 0;
virtual bool OnWorldStarted (cWorld & a_World) = 0;
- virtual bool OnWorldTick (cWorld & a_World, float a_Dt, int a_LastTickDurationMSec) = 0;
+ virtual bool OnWorldTick (cWorld & a_World, std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec) = 0;
/** Handles the command split into a_Split, issued by player a_Player.
Command permissions have already been checked.
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp
index cc3146610..500913e76 100644
--- a/src/Bindings/PluginLua.cpp
+++ b/src/Bindings/PluginLua.cpp
@@ -1430,7 +1430,7 @@ bool cPluginLua::OnWorldStarted(cWorld & a_World)
-bool cPluginLua::OnWorldTick(cWorld & a_World, float a_Dt, int a_LastTickDurationMSec)
+bool cPluginLua::OnWorldTick(cWorld & a_World, std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec)
{
cCSLock Lock(m_CriticalSection);
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_WORLD_TICK];
diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h
index ad3f82b42..f443f5fc0 100644
--- a/src/Bindings/PluginLua.h
+++ b/src/Bindings/PluginLua.h
@@ -128,7 +128,7 @@ public:
virtual bool OnWeatherChanged (cWorld & a_World) override;
virtual bool OnWeatherChanging (cWorld & a_World, eWeather & a_NewWeather) override;
virtual bool OnWorldStarted (cWorld & a_World) override;
- virtual bool OnWorldTick (cWorld & a_World, float a_Dt, int a_LastTickDurationMSec) override;
+ virtual bool OnWorldTick (cWorld & a_World, std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec) override;
virtual bool HandleCommand(const AStringVector & a_Split, cPlayer & a_Player) override;
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index fad0a36d2..58faf54d3 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -1394,7 +1394,7 @@ bool cPluginManager::CallHookWorldStarted(cWorld & a_World)
-bool cPluginManager::CallHookWorldTick(cWorld & a_World, float a_Dt, int a_LastTickDurationMSec)
+bool cPluginManager::CallHookWorldTick(cWorld & a_World, std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec)
{
FIND_HOOK(HOOK_WORLD_TICK);
VERIFY_HOOK;
diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h
index d4b82376a..7b35e92c4 100644
--- a/src/Bindings/PluginManager.h
+++ b/src/Bindings/PluginManager.h
@@ -237,7 +237,7 @@ public:
bool CallHookWeatherChanged (cWorld & a_World);
bool CallHookWeatherChanging (cWorld & a_World, eWeather & a_NewWeather);
bool CallHookWorldStarted (cWorld & a_World);
- bool CallHookWorldTick (cWorld & a_World, float a_Dt, int a_LastTickDurationMSec);
+ bool CallHookWorldTick (cWorld & a_World, std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec);
bool DisablePlugin(const AString & a_PluginName); // tolua_export
bool LoadPlugin (const AString & a_PluginName); // tolua_export
diff --git a/src/BlockEntities/BeaconEntity.cpp b/src/BlockEntities/BeaconEntity.cpp
index 409f2937c..37ce7a8ab 100644
--- a/src/BlockEntities/BeaconEntity.cpp
+++ b/src/BlockEntities/BeaconEntity.cpp
@@ -266,7 +266,7 @@ void cBeaconEntity::GiveEffects(void)
-bool cBeaconEntity::Tick(float a_Dt, cChunk & a_Chunk)
+bool cBeaconEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
// Update the beacon every 4 seconds
if ((GetWorld()->GetWorldAge() % 80) == 0)
diff --git a/src/BlockEntities/BeaconEntity.h b/src/BlockEntities/BeaconEntity.h
index bc27e92b0..4f723c617 100644
--- a/src/BlockEntities/BeaconEntity.h
+++ b/src/BlockEntities/BeaconEntity.h
@@ -30,7 +30,7 @@ public:
// cBlockEntity overrides:
virtual void SendTo(cClientHandle & a_Client) override;
- virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void UsedBy(cPlayer * a_Player) override;
/** Modify the beacon level. (It is needed to load the beacon corectly) */
diff --git a/src/BlockEntities/BlockEntity.h b/src/BlockEntities/BlockEntity.h
index 056a88721..85f75a523 100644
--- a/src/BlockEntities/BlockEntity.h
+++ b/src/BlockEntities/BlockEntity.h
@@ -110,7 +110,7 @@ public:
virtual void SendTo(cClientHandle & a_Client) = 0;
/// Ticks the entity; returns true if the chunk should be marked as dirty as a result of this ticking. By default does nothing.
- virtual bool Tick(float a_Dt, cChunk & a_Chunk)
+ virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
UNUSED(a_Dt);
return false;
diff --git a/src/BlockEntities/CommandBlockEntity.cpp b/src/BlockEntities/CommandBlockEntity.cpp
index b7f938ffd..13c2637dc 100644
--- a/src/BlockEntities/CommandBlockEntity.cpp
+++ b/src/BlockEntities/CommandBlockEntity.cpp
@@ -125,7 +125,7 @@ void cCommandBlockEntity::SetRedstonePower(bool a_IsPowered)
-bool cCommandBlockEntity::Tick(float a_Dt, cChunk & a_Chunk)
+bool cCommandBlockEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
UNUSED(a_Dt);
UNUSED(a_Chunk);
diff --git a/src/BlockEntities/CommandBlockEntity.h b/src/BlockEntities/CommandBlockEntity.h
index d8ac054f0..c525ebc26 100644
--- a/src/BlockEntities/CommandBlockEntity.h
+++ b/src/BlockEntities/CommandBlockEntity.h
@@ -33,7 +33,7 @@ public:
/// Creates a new empty command block entity
cCommandBlockEntity(int a_X, int a_Y, int a_Z, cWorld * a_World);
- virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void SendTo(cClientHandle & a_Client) override;
virtual void UsedBy(cPlayer * a_Player) override;
diff --git a/src/BlockEntities/DropSpenserEntity.cpp b/src/BlockEntities/DropSpenserEntity.cpp
index 3f98836e7..5e98506f1 100644
--- a/src/BlockEntities/DropSpenserEntity.cpp
+++ b/src/BlockEntities/DropSpenserEntity.cpp
@@ -125,7 +125,7 @@ void cDropSpenserEntity::SetRedstonePower(bool a_IsPowered)
-bool cDropSpenserEntity::Tick(float a_Dt, cChunk & a_Chunk)
+bool cDropSpenserEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
UNUSED(a_Dt);
if (!m_ShouldDropSpense)
diff --git a/src/BlockEntities/DropSpenserEntity.h b/src/BlockEntities/DropSpenserEntity.h
index 6c23a402f..83500addb 100644
--- a/src/BlockEntities/DropSpenserEntity.h
+++ b/src/BlockEntities/DropSpenserEntity.h
@@ -47,7 +47,7 @@ public:
virtual ~cDropSpenserEntity();
// cBlockEntity overrides:
- virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void SendTo(cClientHandle & a_Client) override;
virtual void UsedBy(cPlayer * a_Player) override;
diff --git a/src/BlockEntities/FurnaceEntity.cpp b/src/BlockEntities/FurnaceEntity.cpp
index d2ec2bd1e..cc5a00af7 100644
--- a/src/BlockEntities/FurnaceEntity.cpp
+++ b/src/BlockEntities/FurnaceEntity.cpp
@@ -90,7 +90,7 @@ bool cFurnaceEntity::ContinueCooking(void)
-bool cFurnaceEntity::Tick(float a_Dt, cChunk & a_Chunk)
+bool cFurnaceEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
UNUSED(a_Dt);
diff --git a/src/BlockEntities/FurnaceEntity.h b/src/BlockEntities/FurnaceEntity.h
index fbe9d6c75..8b3ba3e36 100644
--- a/src/BlockEntities/FurnaceEntity.h
+++ b/src/BlockEntities/FurnaceEntity.h
@@ -42,7 +42,7 @@ public:
// cBlockEntity overrides:
virtual void SendTo(cClientHandle & a_Client) override;
- virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void UsedBy(cPlayer * a_Player) override;
virtual void Destroy() override
{
diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp
index fe3fb85c4..c2d6cabbb 100644
--- a/src/BlockEntities/HopperEntity.cpp
+++ b/src/BlockEntities/HopperEntity.cpp
@@ -54,7 +54,7 @@ bool cHopperEntity::GetOutputBlockPos(NIBBLETYPE a_BlockMeta, int & a_OutputX, i
-bool cHopperEntity::Tick(float a_Dt, cChunk & a_Chunk)
+bool cHopperEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
UNUSED(a_Dt);
Int64 CurrentTick = a_Chunk.GetWorld()->GetWorldAge();
diff --git a/src/BlockEntities/HopperEntity.h b/src/BlockEntities/HopperEntity.h
index da65aa671..af99c526d 100644
--- a/src/BlockEntities/HopperEntity.h
+++ b/src/BlockEntities/HopperEntity.h
@@ -48,7 +48,7 @@ protected:
Int64 m_LastMoveItemsOutTick;
// cBlockEntity overrides:
- virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void SendTo(cClientHandle & a_Client) override;
virtual void UsedBy(cPlayer * a_Player) override;
diff --git a/src/BlockEntities/MobSpawnerEntity.cpp b/src/BlockEntities/MobSpawnerEntity.cpp
index a7d29638a..9b3f605f9 100644
--- a/src/BlockEntities/MobSpawnerEntity.cpp
+++ b/src/BlockEntities/MobSpawnerEntity.cpp
@@ -73,7 +73,7 @@ void cMobSpawnerEntity::UpdateActiveState(void)
-bool cMobSpawnerEntity::Tick(float a_Dt, cChunk & a_Chunk)
+bool cMobSpawnerEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
// Update the active flag every 5 seconds
if ((m_World->GetWorldAge() % 100) == 0)
diff --git a/src/BlockEntities/MobSpawnerEntity.h b/src/BlockEntities/MobSpawnerEntity.h
index 594b5301e..b572e6657 100644
--- a/src/BlockEntities/MobSpawnerEntity.h
+++ b/src/BlockEntities/MobSpawnerEntity.h
@@ -29,7 +29,7 @@ public:
virtual void SendTo(cClientHandle & a_Client) override;
virtual void UsedBy(cPlayer * a_Player) override;
- virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual bool Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
// tolua_begin
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index b06eed316..979492b46 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -601,7 +601,7 @@ void cChunk::SpawnMobs(cMobSpawner& a_MobSpawner)
-void cChunk::Tick(float a_Dt)
+void cChunk::Tick(std::chrono::milliseconds a_Dt)
{
BroadcastPendingBlockChanges();
diff --git a/src/Chunk.h b/src/Chunk.h
index 6f4ac5cac..1ce862371 100644
--- a/src/Chunk.h
+++ b/src/Chunk.h
@@ -160,7 +160,7 @@ public:
/** Try to Spawn Monsters inside chunk */
void SpawnMobs(cMobSpawner& a_MobSpawner);
- void Tick(float a_Dt);
+ void Tick(std::chrono::milliseconds a_Dt);
/** Ticks a single block. Used by cWorld::TickQueuedBlocks() to tick the queued blocks */
void TickBlock(int a_RelX, int a_RelY, int a_RelZ);
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index c8f5aa673..2dd04f801 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -2720,7 +2720,7 @@ void cChunkMap::SpawnMobs(cMobSpawner& a_MobSpawner)
-void cChunkMap::Tick(float a_Dt)
+void cChunkMap::Tick(std::chrono::milliseconds a_Dt)
{
cCSLock Lock(m_CSLayers);
for (cChunkLayerList::iterator itr = m_Layers.begin(); itr != m_Layers.end(); ++itr)
@@ -2948,7 +2948,7 @@ void cChunkMap::cChunkLayer::SpawnMobs(cMobSpawner& a_MobSpawner)
-void cChunkMap::cChunkLayer::Tick(float a_Dt)
+void cChunkMap::cChunkLayer::Tick(std::chrono::milliseconds a_Dt)
{
for (size_t i = 0; i < ARRAYCOUNT(m_Chunks); i++)
{
diff --git a/src/ChunkMap.h b/src/ChunkMap.h
index fe0bb3733..f08d02337 100644
--- a/src/ChunkMap.h
+++ b/src/ChunkMap.h
@@ -348,7 +348,7 @@ public:
/** Try to Spawn Monsters inside all Chunks */
void SpawnMobs(cMobSpawner& a_MobSpawner);
- void Tick(float a_Dt);
+ void Tick(std::chrono::milliseconds a_Dt);
/** Ticks a single block. Used by cWorld::TickQueuedBlocks() to tick the queued blocks */
void TickBlock(int a_BlockX, int a_BlockY, int a_BlockZ);
@@ -415,7 +415,7 @@ private:
/** Try to Spawn Monsters inside all Chunks */
void SpawnMobs(cMobSpawner& a_MobSpawner);
- void Tick(float a_Dt);
+ void Tick(std::chrono::milliseconds a_Dt);
void RemoveClient(cClientHandle * a_Client);
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index 30f18f677..2ec825ddb 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -174,10 +174,10 @@ void cArrowEntity::CollectedBy(cPlayer & a_Dest)
-void cArrowEntity::Tick(float a_Dt, cChunk & a_Chunk)
+void cArrowEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
- m_Timer += a_Dt;
+ m_Timer += a_Dt.count();
if (m_bIsCollected)
{
@@ -209,7 +209,7 @@ void cArrowEntity::Tick(float a_Dt, cChunk & a_Chunk)
}
else
{
- m_HitGroundTimer += a_Dt;
+ m_HitGroundTimer += a_Dt.count();
}
}
diff --git a/src/Entities/ArrowEntity.h b/src/Entities/ArrowEntity.h
index 436ec0293..8c92049b0 100644
--- a/src/Entities/ArrowEntity.h
+++ b/src/Entities/ArrowEntity.h
@@ -103,6 +103,6 @@ protected:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
virtual void CollectedBy(cPlayer & a_Player) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
}; // tolua_export
diff --git a/src/Entities/Boat.cpp b/src/Entities/Boat.cpp
index 953213bca..6d8b4ef31 100644
--- a/src/Entities/Boat.cpp
+++ b/src/Entities/Boat.cpp
@@ -91,7 +91,7 @@ void cBoat::OnRightClicked(cPlayer & a_Player)
-void cBoat::Tick(float a_Dt, cChunk & a_Chunk)
+void cBoat::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
BroadcastMovementUpdate();
diff --git a/src/Entities/Boat.h b/src/Entities/Boat.h
index 8de88d165..a873ff822 100644
--- a/src/Entities/Boat.h
+++ b/src/Entities/Boat.h
@@ -27,7 +27,7 @@ public:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
virtual bool DoTakeDamage(TakeDamageInfo & TDI) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void HandleSpeedFromAttachee(float a_Forward, float a_Sideways) override;
cBoat(double a_X, double a_Y, double a_Z);
diff --git a/src/Entities/EnderCrystal.cpp b/src/Entities/EnderCrystal.cpp
index 30df2c110..7a911d4db 100644
--- a/src/Entities/EnderCrystal.cpp
+++ b/src/Entities/EnderCrystal.cpp
@@ -29,7 +29,7 @@ void cEnderCrystal::SpawnOn(cClientHandle & a_ClientHandle)
-void cEnderCrystal::Tick(float a_Dt, cChunk & a_Chunk)
+void cEnderCrystal::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
UNUSED(a_Dt);
// No further processing (physics e.t.c.) is needed
diff --git a/src/Entities/EnderCrystal.h b/src/Entities/EnderCrystal.h
index c98c3b681..8f7e2e9b9 100644
--- a/src/Entities/EnderCrystal.h
+++ b/src/Entities/EnderCrystal.h
@@ -23,7 +23,7 @@ private:
// cEntity overrides:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
}; // tolua_export
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 54b9f2a20..c64d94528 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -772,7 +772,7 @@ void cEntity::SetHealth(int a_Health)
-void cEntity::Tick(float a_Dt, cChunk & a_Chunk)
+void cEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
m_TicksAlive++;
@@ -841,7 +841,7 @@ void cEntity::Tick(float a_Dt, cChunk & a_Chunk)
-void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
+void cEntity::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
int BlockX = POSX_TOINT;
int BlockY = POSY_TOINT;
@@ -851,15 +851,15 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
GET_AND_VERIFY_CURRENT_CHUNK(NextChunk, BlockX, BlockZ)
// TODO Add collision detection with entities.
- a_Dt /= 1000; // Convert from msec to sec
+ auto DtSec = std::chrono::duration_cast<std::chrono::duration<double>>(a_Dt);
Vector3d NextPos = Vector3d(GetPosX(), GetPosY(), GetPosZ());
Vector3d NextSpeed = Vector3d(GetSpeedX(), GetSpeedY(), GetSpeedZ());
if ((BlockY >= cChunkDef::Height) || (BlockY < 0))
{
// Outside of the world
- AddSpeedY(m_Gravity * a_Dt);
- AddPosition(GetSpeed() * a_Dt);
+ AddSpeedY(m_Gravity * DtSec.count());
+ AddPosition(GetSpeed() * DtSec.count());
return;
}
@@ -930,8 +930,8 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
float fallspeed;
if (IsBlockWater(BlockIn))
{
- fallspeed = m_Gravity * a_Dt / 3; // Fall 3x slower in water
- ApplyFriction(NextSpeed, 0.7, a_Dt);
+ fallspeed = m_Gravity * DtSec.count() / 3; // Fall 3x slower in water
+ ApplyFriction(NextSpeed, 0.7, DtSec.count());
}
else if (BlockIn == E_BLOCK_COBWEB)
{
@@ -941,13 +941,13 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
else
{
// Normal gravity
- fallspeed = m_Gravity * a_Dt;
+ fallspeed = m_Gravity * DtSec.count();
}
NextSpeed.y += fallspeed;
}
else
{
- ApplyFriction(NextSpeed, 0.7, a_Dt);
+ ApplyFriction(NextSpeed, 0.7, DtSec.count());
}
// Adjust X and Z speed for COBWEB temporary. This speed modification should be handled inside block handlers since we
@@ -1002,14 +1002,14 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
{
cTracer Tracer(GetWorld());
// Distance traced is an integer, so we round up from the distance we should go (Speed * Delta), else we will encounter collision detection failurse
- int DistanceToTrace = (int)(ceil((NextSpeed * a_Dt).SqrLength()) * 2);
+ int DistanceToTrace = (int)(ceil((NextSpeed * DtSec.count()).SqrLength()) * 2);
bool HasHit = Tracer.Trace(NextPos, NextSpeed, DistanceToTrace);
if (HasHit)
{
// Oh noez! We hit something: verify that the (hit position - current) was smaller or equal to the (position that we should travel without obstacles - current)
// This is because previously, we traced with a length that was rounded up (due to integer limitations), and in the case that something was hit, we don't want to overshoot our projected movement
- if ((Tracer.RealHit - NextPos).SqrLength() <= (NextSpeed * a_Dt).SqrLength())
+ if ((Tracer.RealHit - NextPos).SqrLength() <= (NextSpeed * DtSec.count()).SqrLength())
{
// Block hit was within our projected path
// Begin by stopping movement in the direction that we hit something. The Normal is the line perpendicular to a 2D face and in this case, stores what block face was hit through either -1 or 1.
@@ -1044,13 +1044,13 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
// and that this piece of software will come to be hailed as the epitome of performance and functionality in C++, never before seen, and of such a like that will never
// be henceforth seen again in the time of programmers and man alike
// </&sensationalist>
- NextPos += (NextSpeed * a_Dt);
+ NextPos += (NextSpeed * DtSec.count());
}
}
else
{
// We didn't hit anything, so move =]
- NextPos += (NextSpeed * a_Dt);
+ NextPos += (NextSpeed * DtSec.count());
}
}
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index af545fe4a..de9b88dfb 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -326,10 +326,10 @@ public:
// tolua_end
- virtual void Tick(float a_Dt, cChunk & a_Chunk);
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk);
/// Handles the physics of the entity - updates position based on speed, updates speed based on environment
- virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk);
+ virtual void HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk);
/// Updates the state related to this entity being on fire
virtual void TickBurning(cChunk & a_Chunk);
diff --git a/src/Entities/ExpOrb.cpp b/src/Entities/ExpOrb.cpp
index 751308661..9767f96ca 100644
--- a/src/Entities/ExpOrb.cpp
+++ b/src/Entities/ExpOrb.cpp
@@ -42,7 +42,7 @@ void cExpOrb::SpawnOn(cClientHandle & a_Client)
-void cExpOrb::Tick(float a_Dt, cChunk & a_Chunk)
+void cExpOrb::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
cPlayer * a_ClosestPlayer(m_World->FindClosestPlayer(Vector3f(GetPosition()), 5));
if (a_ClosestPlayer != nullptr)
@@ -69,7 +69,7 @@ void cExpOrb::Tick(float a_Dt, cChunk & a_Chunk)
}
HandlePhysics(a_Dt, a_Chunk);
- m_Timer += a_Dt;
+ m_Timer += a_Dt.count();
if (m_Timer >= 1000 * 60 * 5) // 5 minutes
{
Destroy(true);
diff --git a/src/Entities/ExpOrb.h b/src/Entities/ExpOrb.h
index bdb9a5b19..e12e3c504 100644
--- a/src/Entities/ExpOrb.h
+++ b/src/Entities/ExpOrb.h
@@ -22,7 +22,7 @@ public:
cExpOrb(const Vector3d & a_Pos, int a_Reward);
// Override functions
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void SpawnOn(cClientHandle & a_Client) override;
/** Returns the number of ticks that this entity has existed */
diff --git a/src/Entities/FallingBlock.cpp b/src/Entities/FallingBlock.cpp
index 111c5fa84..75105a0cd 100644
--- a/src/Entities/FallingBlock.cpp
+++ b/src/Entities/FallingBlock.cpp
@@ -31,7 +31,7 @@ void cFallingBlock::SpawnOn(cClientHandle & a_ClientHandle)
-void cFallingBlock::Tick(float a_Dt, cChunk & a_Chunk)
+void cFallingBlock::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
// GetWorld()->BroadcastTeleportEntity(*this); // Test position
@@ -82,7 +82,7 @@ void cFallingBlock::Tick(float a_Dt, cChunk & a_Chunk)
return;
}
- float MilliDt = a_Dt * 0.001f;
+ float MilliDt = a_Dt.count() * 0.001f;
AddSpeedY(MilliDt * -9.8f);
AddPosition(GetSpeed() * MilliDt);
diff --git a/src/Entities/FallingBlock.h b/src/Entities/FallingBlock.h
index c20fe8eb9..884938f4d 100644
--- a/src/Entities/FallingBlock.h
+++ b/src/Entities/FallingBlock.h
@@ -30,7 +30,7 @@ public:
// cEntity overrides:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
private:
BLOCKTYPE m_BlockType;
diff --git a/src/Entities/FireworkEntity.cpp b/src/Entities/FireworkEntity.cpp
index 68d02640a..9dc7850a7 100644
--- a/src/Entities/FireworkEntity.cpp
+++ b/src/Entities/FireworkEntity.cpp
@@ -19,7 +19,7 @@ cFireworkEntity::cFireworkEntity(cEntity * a_Creator, double a_X, double a_Y, do
-void cFireworkEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
+void cFireworkEntity::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
int RelX = POSX_TOINT - a_Chunk.GetPosX() * cChunkDef::Width;
int RelZ = POSZ_TOINT - a_Chunk.GetPosZ() * cChunkDef::Width;
@@ -28,7 +28,7 @@ void cFireworkEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
if ((PosY < 0) || (PosY >= cChunkDef::Height))
{
AddSpeedY(1);
- AddPosition(GetSpeed() * (a_Dt / 1000));
+ AddPosition(GetSpeed() * (a_Dt.count() / 1000));
return;
}
@@ -53,14 +53,14 @@ void cFireworkEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
}
AddSpeedY(1);
- AddPosition(GetSpeed() * (a_Dt / 1000));
+ AddPosition(GetSpeed() * (a_Dt.count() / 1000));
}
-void cFireworkEntity::Tick(float a_Dt, cChunk & a_Chunk)
+void cFireworkEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
diff --git a/src/Entities/FireworkEntity.h b/src/Entities/FireworkEntity.h
index 300ec571e..c0a38a943 100644
--- a/src/Entities/FireworkEntity.h
+++ b/src/Entities/FireworkEntity.h
@@ -49,8 +49,8 @@ public:
protected:
// cProjectileEntity overrides:
- virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
private:
diff --git a/src/Entities/Floater.cpp b/src/Entities/Floater.cpp
index 5fe6a1238..cf8dd6c6f 100644
--- a/src/Entities/Floater.cpp
+++ b/src/Entities/Floater.cpp
@@ -125,7 +125,7 @@ void cFloater::SpawnOn(cClientHandle & a_Client)
-void cFloater::Tick(float a_Dt, cChunk & a_Chunk)
+void cFloater::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
HandlePhysics(a_Dt, a_Chunk);
if (IsBlockWater(m_World->GetBlock((int) GetPosX(), (int) GetPosY(), (int) GetPosZ())) && m_World->GetBlockMeta((int) GetPosX(), (int) GetPosY(), (int) GetPosZ()) == 0)
diff --git a/src/Entities/Floater.h b/src/Entities/Floater.h
index 96d77ac82..d5715f89e 100644
--- a/src/Entities/Floater.h
+++ b/src/Entities/Floater.h
@@ -21,7 +21,7 @@ public:
cFloater(double a_X, double a_Y, double a_Z, Vector3d a_Speed, int a_PlayerID, int a_CountDownTime);
virtual void SpawnOn(cClientHandle & a_Client) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
// tolua_begin
bool CanPickup(void) const { return m_CanPickupItem; }
diff --git a/src/Entities/HangingEntity.h b/src/Entities/HangingEntity.h
index 67146a20b..d1ef79a68 100644
--- a/src/Entities/HangingEntity.h
+++ b/src/Entities/HangingEntity.h
@@ -43,7 +43,7 @@ public:
private:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override {}
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override {}
eBlockFace m_Facing;
diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp
index fac4f0714..552d70de7 100644
--- a/src/Entities/Minecart.cpp
+++ b/src/Entities/Minecart.cpp
@@ -111,7 +111,7 @@ void cMinecart::SpawnOn(cClientHandle & a_ClientHandle)
-void cMinecart::HandlePhysics(float a_Dt, cChunk & a_Chunk)
+void cMinecart::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
if (IsDestroyed()) // Mainly to stop detector rails triggering again after minecart is dead
{
@@ -165,19 +165,19 @@ void cMinecart::HandlePhysics(float a_Dt, cChunk & a_Chunk)
switch (InsideType)
{
- case E_BLOCK_RAIL: HandleRailPhysics(InsideMeta, a_Dt); break;
+ case E_BLOCK_RAIL: HandleRailPhysics(InsideMeta, a_Dt.count()); break;
case E_BLOCK_ACTIVATOR_RAIL: break;
case E_BLOCK_POWERED_RAIL: HandlePoweredRailPhysics(InsideMeta); break;
case E_BLOCK_DETECTOR_RAIL:
{
- HandleDetectorRailPhysics(InsideMeta, a_Dt);
+ HandleDetectorRailPhysics(InsideMeta, a_Dt.count());
WasDetectorRail = true;
break;
}
default: VERIFY(!"Unhandled rail type despite checking if block was rail!"); break;
}
- AddPosition(GetSpeed() * (a_Dt / 1000)); // Commit changes; as we use our own engine when on rails, this needs to be done, whereas it is normally in Entity.cpp
+ AddPosition(GetSpeed() * (a_Dt.count() / 1000)); // Commit changes; as we use our own engine when on rails, this needs to be done, whereas it is normally in Entity.cpp
}
else
{
@@ -1213,7 +1213,7 @@ void cMinecartWithFurnace::OnRightClicked(cPlayer & a_Player)
-void cMinecartWithFurnace::Tick(float a_Dt, cChunk & a_Chunk)
+void cMinecartWithFurnace::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
diff --git a/src/Entities/Minecart.h b/src/Entities/Minecart.h
index f7d0d5dda..1c6f4a6c4 100644
--- a/src/Entities/Minecart.h
+++ b/src/Entities/Minecart.h
@@ -38,7 +38,7 @@ public:
// cEntity overrides:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
- virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk) override;
+ virtual void HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual bool DoTakeDamage(TakeDamageInfo & TDI) override;
virtual void Destroyed() override;
@@ -171,7 +171,7 @@ public:
// cEntity overrides:
virtual void OnRightClicked(cPlayer & a_Player) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
// Set functions.
void SetIsFueled(bool a_IsFueled, int a_FueledTimeLeft = -1) {m_IsFueled = a_IsFueled; m_FueledTimeLeft = a_FueledTimeLeft;}
diff --git a/src/Entities/Painting.cpp b/src/Entities/Painting.cpp
index 1aa6da0a1..6f6277f28 100644
--- a/src/Entities/Painting.cpp
+++ b/src/Entities/Painting.cpp
@@ -31,7 +31,7 @@ void cPainting::SpawnOn(cClientHandle & a_Client)
-void cPainting::Tick(float a_Dt, cChunk & a_Chunk)
+void cPainting::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
UNUSED(a_Dt);
UNUSED(a_Chunk);
diff --git a/src/Entities/Painting.h b/src/Entities/Painting.h
index 078270b42..6e8a382fc 100644
--- a/src/Entities/Painting.h
+++ b/src/Entities/Painting.h
@@ -31,7 +31,7 @@ public:
private:
virtual void SpawnOn(cClientHandle & a_Client) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void GetDrops(cItems & a_Items, cEntity * a_Killer) override;
virtual void KilledBy(TakeDamageInfo & a_TDI) override
{
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index fc8ca3d47..baf8a2f3b 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -19,7 +19,7 @@ cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height) :
-void cPawn::Tick(float a_Dt, cChunk & a_Chunk)
+void cPawn::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
// Iterate through this entity's applied effects
for (tEffectMap::iterator iter = m_EntityEffects.begin(); iter != m_EntityEffects.end();)
diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h
index d50bcd8af..e3e99651d 100644
--- a/src/Entities/Pawn.h
+++ b/src/Entities/Pawn.h
@@ -20,7 +20,7 @@ public:
cPawn(eEntityType a_EntityType, double a_Width, double a_Height);
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
// tolua_begin
diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp
index e5e28446d..accb42a63 100644
--- a/src/Entities/Pickup.cpp
+++ b/src/Entities/Pickup.cpp
@@ -110,12 +110,12 @@ void cPickup::SpawnOn(cClientHandle & a_Client)
-void cPickup::Tick(float a_Dt, cChunk & a_Chunk)
+void cPickup::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
BroadcastMovementUpdate(); // Notify clients of position
- m_Timer += a_Dt;
+ m_Timer += a_Dt.count();
if (!m_bCollected)
{
@@ -142,7 +142,7 @@ void cPickup::Tick(float a_Dt, cChunk & a_Chunk)
{
m_bCollected = true;
m_Timer = 0; // We have to reset the timer.
- m_Timer += a_Dt; // In case we have to destroy the pickup in the same tick.
+ m_Timer += a_Dt.count(); // In case we have to destroy the pickup in the same tick.
if (m_Timer > 500.f)
{
Destroy(true);
diff --git a/src/Entities/Pickup.h b/src/Entities/Pickup.h
index d1176a7cf..67f2756ca 100644
--- a/src/Entities/Pickup.h
+++ b/src/Entities/Pickup.h
@@ -34,7 +34,7 @@ public:
bool CollectedBy(cPlayer & a_Dest); // tolua_export
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
/** Returns the number of ticks that this entity has existed */
int GetAge(void) const { return static_cast<int>(m_Timer / 50); } // tolua_export
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 1d5cc6554..1ca131375 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -191,7 +191,7 @@ void cPlayer::SpawnOn(cClientHandle & a_Client)
-void cPlayer::Tick(float a_Dt, cChunk & a_Chunk)
+void cPlayer::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
if (m_ClientHandle != nullptr)
{
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index b94d2659e..d3ed46db6 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -46,9 +46,9 @@ public:
virtual void SpawnOn(cClientHandle & a_Client) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
- virtual void HandlePhysics(float a_Dt, cChunk &) override { UNUSED(a_Dt); }
+ virtual void HandlePhysics(std::chrono::milliseconds a_Dt, cChunk &) override { UNUSED(a_Dt); }
/** Returns the curently equipped weapon; empty item if none */
virtual cItem GetEquippedWeapon(void) const override { return m_Inventory.GetEquippedItem(); }
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp
index 1768714f8..4f20bfae6 100644
--- a/src/Entities/ProjectileEntity.cpp
+++ b/src/Entities/ProjectileEntity.cpp
@@ -331,7 +331,7 @@ AString cProjectileEntity::GetMCAClassName(void) const
-void cProjectileEntity::Tick(float a_Dt, cChunk & a_Chunk)
+void cProjectileEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
@@ -346,7 +346,7 @@ void cProjectileEntity::Tick(float a_Dt, cChunk & a_Chunk)
-void cProjectileEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
+void cProjectileEntity::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
if (m_IsInGround)
{
diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h
index 2a98e31c7..93e442d8c 100644
--- a/src/Entities/ProjectileEntity.h
+++ b/src/Entities/ProjectileEntity.h
@@ -118,8 +118,8 @@ protected:
bool m_IsInGround;
// cEntity overrides:
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
- virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
+ virtual void HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void SpawnOn(cClientHandle & a_Client) override;
} ; // tolua_export
diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h
index 9302d8292..264dc0eb9 100644
--- a/src/Entities/SplashPotionEntity.h
+++ b/src/Entities/SplashPotionEntity.h
@@ -58,7 +58,7 @@ protected:
// cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
- virtual void Tick (float a_Dt, cChunk & a_Chunk) override
+ virtual void Tick (std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override
{
if (m_DestroyTimer > 0)
{
diff --git a/src/Entities/TNTEntity.cpp b/src/Entities/TNTEntity.cpp
index 53af446cc..a89d2f300 100644
--- a/src/Entities/TNTEntity.cpp
+++ b/src/Entities/TNTEntity.cpp
@@ -50,7 +50,7 @@ void cTNTEntity::Explode(void)
-void cTNTEntity::Tick(float a_Dt, cChunk & a_Chunk)
+void cTNTEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
BroadcastMovementUpdate();
diff --git a/src/Entities/TNTEntity.h b/src/Entities/TNTEntity.h
index 48503cf76..9f894338e 100644
--- a/src/Entities/TNTEntity.h
+++ b/src/Entities/TNTEntity.h
@@ -21,7 +21,7 @@ public:
// cEntity overrides:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
// tolua_begin
diff --git a/src/Entities/ThrownEggEntity.cpp b/src/Entities/ThrownEggEntity.cpp
index 24c946a9c..e9ef29239 100644
--- a/src/Entities/ThrownEggEntity.cpp
+++ b/src/Entities/ThrownEggEntity.cpp
@@ -44,7 +44,7 @@ void cThrownEggEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_Hit
-void cThrownEggEntity::Tick(float a_Dt, cChunk & a_Chunk)
+void cThrownEggEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
if (m_DestroyTimer > 0)
{
diff --git a/src/Entities/ThrownEggEntity.h b/src/Entities/ThrownEggEntity.h
index 6ffedf5b5..620927c5d 100644
--- a/src/Entities/ThrownEggEntity.h
+++ b/src/Entities/ThrownEggEntity.h
@@ -35,7 +35,7 @@ protected:
// cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
// Randomly decides whether to spawn a chicken where the egg lands.
void TrySpawnChicken(const Vector3d & a_HitPos);
diff --git a/src/Entities/ThrownEnderPearlEntity.cpp b/src/Entities/ThrownEnderPearlEntity.cpp
index 8f1b62934..f01cdc18c 100644
--- a/src/Entities/ThrownEnderPearlEntity.cpp
+++ b/src/Entities/ThrownEnderPearlEntity.cpp
@@ -46,7 +46,7 @@ void cThrownEnderPearlEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d
-void cThrownEnderPearlEntity::Tick(float a_Dt, cChunk & a_Chunk)
+void cThrownEnderPearlEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
if (m_DestroyTimer > 0)
{
diff --git a/src/Entities/ThrownEnderPearlEntity.h b/src/Entities/ThrownEnderPearlEntity.h
index 475ebde87..94f3ab5cb 100644
--- a/src/Entities/ThrownEnderPearlEntity.h
+++ b/src/Entities/ThrownEnderPearlEntity.h
@@ -35,7 +35,7 @@ protected:
// cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
/** Teleports the creator where the ender pearl lands */
void TeleportCreator(const Vector3d & a_HitPos);
diff --git a/src/Entities/ThrownSnowballEntity.cpp b/src/Entities/ThrownSnowballEntity.cpp
index 88e39d22e..24db1e7ee 100644
--- a/src/Entities/ThrownSnowballEntity.cpp
+++ b/src/Entities/ThrownSnowballEntity.cpp
@@ -48,7 +48,7 @@ void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d &
-void cThrownSnowballEntity::Tick(float a_Dt, cChunk & a_Chunk)
+void cThrownSnowballEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
if (m_DestroyTimer > 0)
{
diff --git a/src/Entities/ThrownSnowballEntity.h b/src/Entities/ThrownSnowballEntity.h
index f806996cc..391b0c40b 100644
--- a/src/Entities/ThrownSnowballEntity.h
+++ b/src/Entities/ThrownSnowballEntity.h
@@ -35,7 +35,7 @@ protected:
// cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
private:
diff --git a/src/Globals.h b/src/Globals.h
index b8e9ec7ed..f0726454b 100644
--- a/src/Globals.h
+++ b/src/Globals.h
@@ -421,6 +421,7 @@ std::unique_ptr<T> make_unique(Args&&... args)
// a tick is 50 ms
using cTickTime = std::chrono::duration<int, std::ratio_multiply<std::chrono::milliseconds::period, std::ratio<50>>>;
+using cTickTimeLong = std::chrono::duration<Int64, cTickTime::period>;
#ifndef TOLUA_TEMPLATE_BIND
#define TOLUA_TEMPLATE_BIND(x)
diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp
index 7ca7a9d66..b9e80c01d 100644
--- a/src/Mobs/AggressiveMonster.cpp
+++ b/src/Mobs/AggressiveMonster.cpp
@@ -61,7 +61,7 @@ void cAggressiveMonster::EventSeePlayer(cEntity * a_Entity)
-void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk)
+void cAggressiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
@@ -93,9 +93,9 @@ void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk)
-void cAggressiveMonster::Attack(float a_Dt)
+void cAggressiveMonster::Attack(std::chrono::milliseconds a_Dt)
{
- m_AttackInterval += a_Dt * m_AttackRate;
+ m_AttackInterval += a_Dt.count() * m_AttackRate;
if ((m_Target == nullptr) || (m_AttackInterval < 3.0))
{
diff --git a/src/Mobs/AggressiveMonster.h b/src/Mobs/AggressiveMonster.h
index 2549ba2d3..932915055 100644
--- a/src/Mobs/AggressiveMonster.h
+++ b/src/Mobs/AggressiveMonster.h
@@ -16,11 +16,11 @@ public:
cAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
- virtual void Tick (float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick (std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void InStateChasing(float a_Dt) override;
virtual void EventSeePlayer(cEntity *) override;
- virtual void Attack(float a_Dt);
+ virtual void Attack(std::chrono::milliseconds a_Dt);
protected:
/** Whether this mob's destination is the same as its target's position. */
diff --git a/src/Mobs/Blaze.cpp b/src/Mobs/Blaze.cpp
index 1fa9d2c37..172ccd071 100644
--- a/src/Mobs/Blaze.cpp
+++ b/src/Mobs/Blaze.cpp
@@ -30,9 +30,9 @@ void cBlaze::GetDrops(cItems & a_Drops, cEntity * a_Killer)
-void cBlaze::Attack(float a_Dt)
+void cBlaze::Attack(std::chrono::milliseconds a_Dt)
{
- m_AttackInterval += a_Dt * m_AttackRate;
+ m_AttackInterval += a_Dt.count() * m_AttackRate;
if ((m_Target != nullptr) && (m_AttackInterval > 3.0))
{
diff --git a/src/Mobs/Blaze.h b/src/Mobs/Blaze.h
index e2a4ad9f1..493953a14 100644
--- a/src/Mobs/Blaze.h
+++ b/src/Mobs/Blaze.h
@@ -18,5 +18,5 @@ public:
CLASS_PROTODEF(cBlaze)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
- virtual void Attack(float a_Dt) override;
+ virtual void Attack(std::chrono::milliseconds a_Dt) override;
} ;
diff --git a/src/Mobs/CaveSpider.cpp b/src/Mobs/CaveSpider.cpp
index 045b47e73..fa530db82 100644
--- a/src/Mobs/CaveSpider.cpp
+++ b/src/Mobs/CaveSpider.cpp
@@ -16,7 +16,7 @@ cCaveSpider::cCaveSpider(void) :
-void cCaveSpider::Tick(float a_Dt, cChunk & a_Chunk)
+void cCaveSpider::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
@@ -27,7 +27,7 @@ void cCaveSpider::Tick(float a_Dt, cChunk & a_Chunk)
-void cCaveSpider::Attack(float a_Dt)
+void cCaveSpider::Attack(std::chrono::milliseconds a_Dt)
{
super::Attack(a_Dt);
diff --git a/src/Mobs/CaveSpider.h b/src/Mobs/CaveSpider.h
index 494ba1360..d3e56fd2b 100644
--- a/src/Mobs/CaveSpider.h
+++ b/src/Mobs/CaveSpider.h
@@ -16,8 +16,8 @@ public:
CLASS_PROTODEF(cCaveSpider)
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
- virtual void Attack(float a_Dt) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
+ virtual void Attack(std::chrono::milliseconds a_Dt) override;
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
} ;
diff --git a/src/Mobs/Chicken.cpp b/src/Mobs/Chicken.cpp
index 634867cfa..b2b21d4ae 100644
--- a/src/Mobs/Chicken.cpp
+++ b/src/Mobs/Chicken.cpp
@@ -18,7 +18,7 @@ cChicken::cChicken(void) :
-void cChicken::Tick(float a_Dt, cChunk & a_Chunk)
+void cChicken::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
diff --git a/src/Mobs/Chicken.h b/src/Mobs/Chicken.h
index 07b921884..9349187c6 100644
--- a/src/Mobs/Chicken.h
+++ b/src/Mobs/Chicken.h
@@ -17,7 +17,7 @@ public:
CLASS_PROTODEF(cChicken)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_SEEDS); }
diff --git a/src/Mobs/Creeper.cpp b/src/Mobs/Creeper.cpp
index a073224cf..c4ae47f2f 100644
--- a/src/Mobs/Creeper.cpp
+++ b/src/Mobs/Creeper.cpp
@@ -23,7 +23,7 @@ cCreeper::cCreeper(void) :
-void cCreeper::Tick(float a_Dt, cChunk & a_Chunk)
+void cCreeper::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
@@ -119,7 +119,7 @@ bool cCreeper::DoTakeDamage(TakeDamageInfo & a_TDI)
-void cCreeper::Attack(float a_Dt)
+void cCreeper::Attack(std::chrono::milliseconds a_Dt)
{
UNUSED(a_Dt);
diff --git a/src/Mobs/Creeper.h b/src/Mobs/Creeper.h
index bf3272e22..1827c416e 100644
--- a/src/Mobs/Creeper.h
+++ b/src/Mobs/Creeper.h
@@ -19,8 +19,8 @@ public:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
- virtual void Attack(float a_Dt) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Attack(std::chrono::milliseconds a_Dt) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
bool IsBlowing(void) const {return m_bIsBlowing; }
diff --git a/src/Mobs/Enderman.cpp b/src/Mobs/Enderman.cpp
index 56ea10245..42c33884a 100644
--- a/src/Mobs/Enderman.cpp
+++ b/src/Mobs/Enderman.cpp
@@ -186,7 +186,7 @@ bool cEnderman::CheckLight()
-void cEnderman::Tick(float a_Dt, cChunk & a_Chunk)
+void cEnderman::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
diff --git a/src/Mobs/Enderman.h b/src/Mobs/Enderman.h
index 28bbceb84..8ccbf2ce7 100644
--- a/src/Mobs/Enderman.h
+++ b/src/Mobs/Enderman.h
@@ -21,7 +21,7 @@ public:
virtual void CheckEventSeePlayer(void) override;
virtual void CheckEventLostPlayer(void) override;
virtual void EventLosePlayer(void) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
bool IsScreaming(void) const {return m_bIsScreaming; }
BLOCKTYPE GetCarriedBlock(void) const {return CarriedBlock; }
diff --git a/src/Mobs/Ghast.cpp b/src/Mobs/Ghast.cpp
index fc8de8362..ea0295102 100644
--- a/src/Mobs/Ghast.cpp
+++ b/src/Mobs/Ghast.cpp
@@ -32,9 +32,9 @@ void cGhast::GetDrops(cItems & a_Drops, cEntity * a_Killer)
-void cGhast::Attack(float a_Dt)
+void cGhast::Attack(std::chrono::milliseconds a_Dt)
{
- m_AttackInterval += a_Dt * m_AttackRate;
+ m_AttackInterval += a_Dt.count() * m_AttackRate;
if ((m_Target != nullptr) && (m_AttackInterval > 3.0))
{
diff --git a/src/Mobs/Ghast.h b/src/Mobs/Ghast.h
index a28940a01..431edaf6d 100644
--- a/src/Mobs/Ghast.h
+++ b/src/Mobs/Ghast.h
@@ -18,7 +18,7 @@ public:
CLASS_PROTODEF(cGhast)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
- virtual void Attack(float a_Dt) override;
+ virtual void Attack(std::chrono::milliseconds a_Dt) override;
bool IsCharging(void) const {return false; }
} ;
diff --git a/src/Mobs/Guardian.cpp b/src/Mobs/Guardian.cpp
index 15908d801..5eb30785b 100644
--- a/src/Mobs/Guardian.cpp
+++ b/src/Mobs/Guardian.cpp
@@ -35,7 +35,7 @@ void cGuardian::GetDrops(cItems & a_Drops, cEntity * a_Killer)
-void cGuardian::Tick(float a_Dt, cChunk & a_Chunk)
+void cGuardian::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
// We must first process current location, and only then tick, otherwise we risk processing a location in a chunk
// that is not where the entity currently resides (FS #411)
diff --git a/src/Mobs/Guardian.h b/src/Mobs/Guardian.h
index 50c034036..6bc17947c 100644
--- a/src/Mobs/Guardian.h
+++ b/src/Mobs/Guardian.h
@@ -15,7 +15,7 @@ class cGuardian :
public:
cGuardian();
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
CLASS_PROTODEF(cGuardian)
diff --git a/src/Mobs/Horse.cpp b/src/Mobs/Horse.cpp
index d92f0d023..5b4c78bfc 100644
--- a/src/Mobs/Horse.cpp
+++ b/src/Mobs/Horse.cpp
@@ -30,7 +30,7 @@ cHorse::cHorse(int Type, int Color, int Style, int TameTimes) :
-void cHorse::Tick(float a_Dt, cChunk & a_Chunk)
+void cHorse::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
diff --git a/src/Mobs/Horse.h b/src/Mobs/Horse.h
index 4c644e512..be283705e 100644
--- a/src/Mobs/Horse.h
+++ b/src/Mobs/Horse.h
@@ -18,7 +18,7 @@ public:
CLASS_PROTODEF(cHorse)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
bool IsSaddled (void) const {return m_bIsSaddled; }
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 425c80bf4..30bbd0ff2 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -252,14 +252,14 @@ bool cMonster::ReachedFinalDestination()
-void cMonster::Tick(float a_Dt, cChunk & a_Chunk)
+void cMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
if (m_Health <= 0)
{
// The mob is dead, but we're still animating the "puff" they leave when they die
- m_DestroyTimer += a_Dt / 1000;
+ m_DestroyTimer += a_Dt.count() / 1000;
if (m_DestroyTimer > 1)
{
Destroy(true);
@@ -275,8 +275,6 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk)
// Burning in daylight
HandleDaylightBurning(a_Chunk);
- a_Dt /= 1000;
-
if (m_bMovingToDestination)
{
if (m_bOnGround)
@@ -347,18 +345,18 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk)
case IDLE:
{
// If enemy passive we ignore checks for player visibility
- InStateIdle(a_Dt);
+ InStateIdle(std::chrono::duration_cast<std::chrono::seconds>(a_Dt).count());
break;
}
case CHASING:
{
// If we do not see a player anymore skip chasing action
- InStateChasing(a_Dt);
+ InStateChasing(std::chrono::duration_cast<std::chrono::seconds>(a_Dt).count());
break;
}
case ESCAPING:
{
- InStateEscaping(a_Dt);
+ InStateEscaping(std::chrono::duration_cast<std::chrono::seconds>(a_Dt).count());
break;
}
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index fb1bc550d..5752a2040 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -52,7 +52,7 @@ public:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
diff --git a/src/Mobs/PassiveMonster.cpp b/src/Mobs/PassiveMonster.cpp
index 1048616d0..012ca9949 100644
--- a/src/Mobs/PassiveMonster.cpp
+++ b/src/Mobs/PassiveMonster.cpp
@@ -35,7 +35,7 @@ bool cPassiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
-void cPassiveMonster::Tick(float a_Dt, cChunk & a_Chunk)
+void cPassiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
diff --git a/src/Mobs/PassiveMonster.h b/src/Mobs/PassiveMonster.h
index 9221d9a6e..2ed2cd21d 100644
--- a/src/Mobs/PassiveMonster.h
+++ b/src/Mobs/PassiveMonster.h
@@ -15,7 +15,7 @@ class cPassiveMonster :
public:
cPassiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
/// When hit by someone, run away
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
diff --git a/src/Mobs/Pig.cpp b/src/Mobs/Pig.cpp
index 1e4c35acd..edd4d9de4 100644
--- a/src/Mobs/Pig.cpp
+++ b/src/Mobs/Pig.cpp
@@ -80,7 +80,7 @@ void cPig::OnRightClicked(cPlayer & a_Player)
-void cPig::Tick(float a_Dt, cChunk & a_Chunk)
+void cPig::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
diff --git a/src/Mobs/Pig.h b/src/Mobs/Pig.h
index 0e026933a..0fe4b4fed 100644
--- a/src/Mobs/Pig.h
+++ b/src/Mobs/Pig.h
@@ -22,7 +22,7 @@ public:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_CARROT); }
diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp
index c46404391..e4d1760e0 100644
--- a/src/Mobs/Sheep.cpp
+++ b/src/Mobs/Sheep.cpp
@@ -84,7 +84,7 @@ void cSheep::OnRightClicked(cPlayer & a_Player)
-void cSheep::Tick(float a_Dt, cChunk & a_Chunk)
+void cSheep::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
int PosX = POSX_TOINT;
diff --git a/src/Mobs/Sheep.h b/src/Mobs/Sheep.h
index 16d5fddd3..b6c99ac2a 100644
--- a/src/Mobs/Sheep.h
+++ b/src/Mobs/Sheep.h
@@ -24,7 +24,7 @@ public:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_WHEAT); }
diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp
index da5ddc670..dd59d6454 100644
--- a/src/Mobs/Skeleton.cpp
+++ b/src/Mobs/Skeleton.cpp
@@ -67,9 +67,9 @@ void cSkeleton::MoveToPosition(const Vector3d & a_Position)
-void cSkeleton::Attack(float a_Dt)
+void cSkeleton::Attack(std::chrono::milliseconds a_Dt)
{
- m_AttackInterval += a_Dt * m_AttackRate;
+ m_AttackInterval += a_Dt.count() * m_AttackRate;
if ((m_Target != nullptr) && (m_AttackInterval > 3.0))
{
diff --git a/src/Mobs/Skeleton.h b/src/Mobs/Skeleton.h
index cd1c6c3f0..9c49c52fb 100644
--- a/src/Mobs/Skeleton.h
+++ b/src/Mobs/Skeleton.h
@@ -19,7 +19,7 @@ public:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void MoveToPosition(const Vector3d & a_Position) override;
- virtual void Attack(float a_Dt) override;
+ virtual void Attack(std::chrono::milliseconds a_Dt) override;
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual bool IsUndead(void) override { return true; }
diff --git a/src/Mobs/Slime.cpp b/src/Mobs/Slime.cpp
index 1c68c5189..e42501e47 100644
--- a/src/Mobs/Slime.cpp
+++ b/src/Mobs/Slime.cpp
@@ -46,7 +46,7 @@ void cSlime::GetDrops(cItems & a_Drops, cEntity * a_Killer)
-void cSlime::Attack(float a_Dt)
+void cSlime::Attack(std::chrono::milliseconds a_Dt)
{
if (m_Size > 1)
{
diff --git a/src/Mobs/Slime.h b/src/Mobs/Slime.h
index a177a279c..29605992d 100644
--- a/src/Mobs/Slime.h
+++ b/src/Mobs/Slime.h
@@ -20,7 +20,7 @@ public:
// cAggressiveMonster overrides:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
- virtual void Attack(float a_Dt) override;
+ virtual void Attack(std::chrono::milliseconds a_Dt) override;
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
int GetSize(void) const { return m_Size; }
diff --git a/src/Mobs/SnowGolem.cpp b/src/Mobs/SnowGolem.cpp
index 8c4178beb..e1510b203 100644
--- a/src/Mobs/SnowGolem.cpp
+++ b/src/Mobs/SnowGolem.cpp
@@ -27,7 +27,7 @@ void cSnowGolem::GetDrops(cItems & a_Drops, cEntity * a_Killer)
-void cSnowGolem::Tick(float a_Dt, cChunk & a_Chunk)
+void cSnowGolem::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
if (IsBiomeNoDownfall(m_World->GetBiomeAt((int) floor(GetPosX()), (int) floor(GetPosZ()))))
diff --git a/src/Mobs/SnowGolem.h b/src/Mobs/SnowGolem.h
index f036b1867..9c95e21c5 100644
--- a/src/Mobs/SnowGolem.h
+++ b/src/Mobs/SnowGolem.h
@@ -17,7 +17,7 @@ public:
CLASS_PROTODEF(cSnowGolem)
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
} ;
diff --git a/src/Mobs/Squid.cpp b/src/Mobs/Squid.cpp
index 59ee963ae..3c508b65f 100644
--- a/src/Mobs/Squid.cpp
+++ b/src/Mobs/Squid.cpp
@@ -33,7 +33,7 @@ void cSquid::GetDrops(cItems & a_Drops, cEntity * a_Killer)
-void cSquid::Tick(float a_Dt, cChunk & a_Chunk)
+void cSquid::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
// We must first process current location, and only then tick, otherwise we risk processing a location in a chunk
// that is not where the entity currently resides (FS #411)
diff --git a/src/Mobs/Squid.h b/src/Mobs/Squid.h
index a46d738c6..7e944a17e 100644
--- a/src/Mobs/Squid.h
+++ b/src/Mobs/Squid.h
@@ -15,7 +15,7 @@ class cSquid :
public:
cSquid();
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
CLASS_PROTODEF(cSquid)
diff --git a/src/Mobs/Villager.cpp b/src/Mobs/Villager.cpp
index 963595347..6f647ac18 100644
--- a/src/Mobs/Villager.cpp
+++ b/src/Mobs/Villager.cpp
@@ -51,7 +51,7 @@ bool cVillager::DoTakeDamage(TakeDamageInfo & a_TDI)
-void cVillager::Tick(float a_Dt, cChunk & a_Chunk)
+void cVillager::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
diff --git a/src/Mobs/Villager.h b/src/Mobs/Villager.h
index d3a38dbf0..2de79295c 100644
--- a/src/Mobs/Villager.h
+++ b/src/Mobs/Villager.h
@@ -31,7 +31,7 @@ public:
// cEntity overrides
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
- virtual void Tick (float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick (std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
// cVillager functions
/** return true if the given blocktype are: crops, potatoes or carrots.*/
diff --git a/src/Mobs/Wither.cpp b/src/Mobs/Wither.cpp
index 578b47995..6ef81ce1b 100644
--- a/src/Mobs/Wither.cpp
+++ b/src/Mobs/Wither.cpp
@@ -66,7 +66,7 @@ bool cWither::DoTakeDamage(TakeDamageInfo & a_TDI)
-void cWither::Tick(float a_Dt, cChunk & a_Chunk)
+void cWither::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h
index a20fed3d3..9e333c7fa 100644
--- a/src/Mobs/Wither.h
+++ b/src/Mobs/Wither.h
@@ -28,7 +28,7 @@ public:
virtual bool Initialize(cWorld & a_World) override;
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
virtual bool IsUndead(void) override { return true; }
diff --git a/src/Mobs/Wolf.cpp b/src/Mobs/Wolf.cpp
index 4711d5a7a..b3eefdf79 100644
--- a/src/Mobs/Wolf.cpp
+++ b/src/Mobs/Wolf.cpp
@@ -43,7 +43,7 @@ bool cWolf::DoTakeDamage(TakeDamageInfo & a_TDI)
-void cWolf::Attack(float a_Dt)
+void cWolf::Attack(std::chrono::milliseconds a_Dt)
{
UNUSED(a_Dt);
@@ -145,7 +145,7 @@ void cWolf::OnRightClicked(cPlayer & a_Player)
-void cWolf::Tick(float a_Dt, cChunk & a_Chunk)
+void cWolf::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
if (!IsAngry())
{
diff --git a/src/Mobs/Wolf.h b/src/Mobs/Wolf.h
index 7500854f8..73ffb55c2 100644
--- a/src/Mobs/Wolf.h
+++ b/src/Mobs/Wolf.h
@@ -20,9 +20,9 @@ public:
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void TickFollowPlayer();
- virtual void Attack(float a_Dt) override;
+ virtual void Attack(std::chrono::milliseconds a_Dt) override;
// Get functions
bool IsSitting (void) const { return m_IsSitting; }
diff --git a/src/Simulator/DelayedFluidSimulator.cpp b/src/Simulator/DelayedFluidSimulator.cpp
index dc8dffe2d..0973962b6 100644
--- a/src/Simulator/DelayedFluidSimulator.cpp
+++ b/src/Simulator/DelayedFluidSimulator.cpp
@@ -130,7 +130,7 @@ void cDelayedFluidSimulator::Simulate(float a_Dt)
-void cDelayedFluidSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk)
+void cDelayedFluidSimulator::SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk)
{
void * ChunkDataRaw = (m_FluidBlock == E_BLOCK_WATER) ? a_Chunk->GetWaterSimulatorData() : a_Chunk->GetLavaSimulatorData();
cDelayedFluidSimulatorChunkData * ChunkData = (cDelayedFluidSimulatorChunkData *)ChunkDataRaw;
diff --git a/src/Simulator/DelayedFluidSimulator.h b/src/Simulator/DelayedFluidSimulator.h
index 8a6c26c7a..e3182812d 100644
--- a/src/Simulator/DelayedFluidSimulator.h
+++ b/src/Simulator/DelayedFluidSimulator.h
@@ -56,7 +56,7 @@ public:
// cSimulator overrides:
virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override;
virtual void Simulate(float a_Dt) override;
- virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override;
+ virtual void SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override;
virtual cFluidSimulatorData * CreateChunkData(void) override { return new cDelayedFluidSimulatorChunkData(m_TickDelay); }
protected:
diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp
index 75ebefcf7..0439ebdca 100644
--- a/src/Simulator/FireSimulator.cpp
+++ b/src/Simulator/FireSimulator.cpp
@@ -88,11 +88,11 @@ cFireSimulator::~cFireSimulator()
-void cFireSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk)
+void cFireSimulator::SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk)
{
cCoordWithIntList & Data = a_Chunk->GetFireSimulatorData();
- int NumMSecs = (int)a_Dt;
+ int NumMSecs = a_Dt.count();
for (cCoordWithIntList::iterator itr = Data.begin(); itr != Data.end();)
{
int x = itr->x;
diff --git a/src/Simulator/FireSimulator.h b/src/Simulator/FireSimulator.h
index 9ccc3ef4f..a40e29565 100644
--- a/src/Simulator/FireSimulator.h
+++ b/src/Simulator/FireSimulator.h
@@ -23,7 +23,7 @@ public:
~cFireSimulator();
virtual void Simulate(float a_Dt) override { UNUSED(a_Dt);} // not used
- virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override;
+ virtual void SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override;
virtual bool IsAllowedBlock(BLOCKTYPE a_BlockType) override;
diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp
index 7ff499eb5..1cc5340dd 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.cpp
+++ b/src/Simulator/IncrementalRedstoneSimulator.cpp
@@ -145,7 +145,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
-void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk)
+void cIncrementalRedstoneSimulator::SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk)
{
m_RedstoneSimulatorChunkData = (cIncrementalRedstoneSimulator::cIncrementalRedstoneSimulatorChunkData *)a_Chunk->GetRedstoneSimulatorData();
if (m_RedstoneSimulatorChunkData == nullptr)
diff --git a/src/Simulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator.h
index 3d2962c08..43f0e89d0 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.h
+++ b/src/Simulator/IncrementalRedstoneSimulator.h
@@ -32,7 +32,7 @@ public:
}
virtual void Simulate(float a_Dt) override { UNUSED(a_Dt); } // not used
- virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override;
+ virtual void SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override;
virtual bool IsAllowedBlock(BLOCKTYPE a_BlockType) override { return IsRedstone(a_BlockType); }
virtual void WakeUp(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override;
diff --git a/src/Simulator/NoopRedstoneSimulator.h b/src/Simulator/NoopRedstoneSimulator.h
index 4e05529f5..b8c797472 100644
--- a/src/Simulator/NoopRedstoneSimulator.h
+++ b/src/Simulator/NoopRedstoneSimulator.h
@@ -21,7 +21,7 @@ public:
// ~cRedstoneNoopSimulator();
virtual void Simulate(float a_Dt) override { UNUSED(a_Dt);} // not used
- virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override
+ virtual void SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override
{
UNUSED(a_Dt);
UNUSED(a_ChunkX);
diff --git a/src/Simulator/SandSimulator.cpp b/src/Simulator/SandSimulator.cpp
index dfbd3e458..497f81999 100644
--- a/src/Simulator/SandSimulator.cpp
+++ b/src/Simulator/SandSimulator.cpp
@@ -24,7 +24,7 @@ cSandSimulator::cSandSimulator(cWorld & a_World, cIniFile & a_IniFile) :
-void cSandSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk)
+void cSandSimulator::SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk)
{
cSandSimulatorChunkData & ChunkData = a_Chunk->GetSandSimulatorData();
if (ChunkData.empty())
diff --git a/src/Simulator/SandSimulator.h b/src/Simulator/SandSimulator.h
index 93b1de8e2..8fff659ed 100644
--- a/src/Simulator/SandSimulator.h
+++ b/src/Simulator/SandSimulator.h
@@ -18,7 +18,7 @@ public:
// cSimulator overrides:
virtual void Simulate(float a_Dt) override { UNUSED(a_Dt);} // not used
- virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override;
+ virtual void SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override;
virtual bool IsAllowedBlock(BLOCKTYPE a_BlockType) override;
/// Returns true if a falling-able block can start falling through the specified block type
diff --git a/src/Simulator/Simulator.h b/src/Simulator/Simulator.h
index f28a07e35..c8066edfd 100644
--- a/src/Simulator/Simulator.h
+++ b/src/Simulator/Simulator.h
@@ -24,7 +24,7 @@ public:
virtual void Simulate(float a_Dt) = 0;
/// Called in each tick for each chunk, a_Dt is the time passed since the last tick, in msec; direct access to chunk data available
- virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk)
+ virtual void SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk)
{
UNUSED(a_Dt);
UNUSED(a_ChunkX);
diff --git a/src/Simulator/SimulatorManager.cpp b/src/Simulator/SimulatorManager.cpp
index 918bac7a1..e74642fc0 100644
--- a/src/Simulator/SimulatorManager.cpp
+++ b/src/Simulator/SimulatorManager.cpp
@@ -42,7 +42,7 @@ void cSimulatorManager::Simulate(float a_Dt)
-void cSimulatorManager::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk)
+void cSimulatorManager::SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk)
{
// m_Ticks has already been increased in Simulate()
for (cSimulators::iterator itr = m_Simulators.begin(); itr != m_Simulators.end(); ++itr)
diff --git a/src/Simulator/SimulatorManager.h b/src/Simulator/SimulatorManager.h
index 31a709316..b96f6ca84 100644
--- a/src/Simulator/SimulatorManager.h
+++ b/src/Simulator/SimulatorManager.h
@@ -33,7 +33,7 @@ public:
void Simulate(float a_Dt);
- void SimulateChunk(float a_DT, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk);
+ void SimulateChunk(std::chrono::milliseconds a_DT, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk);
void WakeUp(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk);
diff --git a/src/World.cpp b/src/World.cpp
index 2dd03497b..cd99f2c2d 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -238,9 +238,8 @@ void cWorld::cTickThread::Execute(void)
while (!m_ShouldTerminate)
{
auto NowTime = std::chrono::steady_clock::now();
- auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(NowTime - LastTime).count();
- auto LastTickMsec = std::chrono::duration_cast<std::chrono::duration<int>>(TickTime).count();
- m_World.Tick(static_cast<float>(msec), LastTickMsec);
+ auto WaitTime = std::chrono::duration_cast<std::chrono::milliseconds>(NowTime - LastTime);
+ m_World.Tick(WaitTime, TickTime);
TickTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - NowTime);
if (TickTime < cTickTime(1))
@@ -273,8 +272,6 @@ cWorld::cWorld(const AString & a_WorldName, eDimension a_Dimension, const AStrin
m_Dimension(a_Dimension),
m_IsSpawnExplicitlySet(false),
m_IsDaylightCycleEnabled(true),
- m_WorldAgeSecs(0),
- m_TimeOfDaySecs(0),
m_WorldAge(0),
m_TimeOfDay(0),
m_LastTimeUpdate(0),
@@ -617,7 +614,7 @@ void cWorld::Start(void)
InitialiseGeneratorDefaults(IniFile);
InitialiseAndLoadMobSpawningValues(IniFile);
- SetTimeOfDay(IniFile.GetValueSetI("General", "TimeInTicks", m_TimeOfDay));
+ SetTimeOfDay(IniFile.GetValueSetI("General", "TimeInTicks", GetTimeOfDay()));
m_ChunkMap = make_unique<cChunkMap>(this);
@@ -644,10 +641,10 @@ void cWorld::Start(void)
m_TickThread.Start();
// Init of the spawn monster time (as they are supposed to have different spawn rate)
- m_LastSpawnMonster.insert(std::map<cMonster::eFamily, Int64>::value_type(cMonster::mfHostile, 0));
- m_LastSpawnMonster.insert(std::map<cMonster::eFamily, Int64>::value_type(cMonster::mfPassive, 0));
- m_LastSpawnMonster.insert(std::map<cMonster::eFamily, Int64>::value_type(cMonster::mfAmbient, 0));
- m_LastSpawnMonster.insert(std::map<cMonster::eFamily, Int64>::value_type(cMonster::mfWater, 0));
+ m_LastSpawnMonster.insert(std::map<cMonster::eFamily, cTickTimeLong>::value_type(cMonster::mfHostile, cTickTimeLong(0)));
+ m_LastSpawnMonster.insert(std::map<cMonster::eFamily, cTickTimeLong>::value_type(cMonster::mfPassive, cTickTimeLong(0)));
+ m_LastSpawnMonster.insert(std::map<cMonster::eFamily, cTickTimeLong>::value_type(cMonster::mfAmbient, cTickTimeLong(0)));
+ m_LastSpawnMonster.insert(std::map<cMonster::eFamily, cTickTimeLong>::value_type(cMonster::mfWater, cTickTimeLong(0)));
m_MapManager.LoadMapData();
@@ -838,7 +835,7 @@ void cWorld::Stop(void)
IniFile.SetValueB("Mechanics", "UseChatPrefixes", m_bUseChatPrefixes);
IniFile.SetValueB("General", "IsDaylightCycleEnabled", m_IsDaylightCycleEnabled);
IniFile.SetValueI("General", "Weather", (int)m_Weather);
- IniFile.SetValueI("General", "TimeInTicks", m_TimeOfDay);
+ IniFile.SetValueI("General", "TimeInTicks", GetTimeOfDay());
IniFile.WriteFile(m_IniFileName);
m_TickThread.Stop();
@@ -852,7 +849,7 @@ void cWorld::Stop(void)
-void cWorld::Tick(float a_Dt, int a_LastTickDurationMSec)
+void cWorld::Tick(std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec)
{
// Call the plugins
cPluginManager::Get()->CallHookWorldTick(*this, a_Dt, a_LastTickDurationMSec);
@@ -868,30 +865,27 @@ void cWorld::Tick(float a_Dt, int a_LastTickDurationMSec)
SetChunkData(**itr);
} // for itr - SetChunkDataQueue[]
- m_WorldAgeSecs += (double)a_Dt / 1000.0;
- m_WorldAge = (Int64)(m_WorldAgeSecs * 20.0);
+ m_WorldAge += a_Dt;
if (m_IsDaylightCycleEnabled)
{
// We need sub-tick precision here, that's why we store the time in seconds and calculate ticks off of it
- m_TimeOfDaySecs += (double)a_Dt / 1000.0;
+ m_TimeOfDay += a_Dt;
// Wrap time of day each 20 minutes (1200 seconds)
- if (m_TimeOfDaySecs > 1200.0)
+ if (m_TimeOfDay > std::chrono::minutes(20))
{
- m_TimeOfDaySecs -= 1200.0;
+ m_TimeOfDay -= std::chrono::minutes(20);
}
- m_TimeOfDay = static_cast<int>(m_TimeOfDaySecs * 20.0);
-
// Updates the sky darkness based on current time of day
UpdateSkyDarkness();
// Broadcast time update every 40 ticks (2 seconds)
- if (m_LastTimeUpdate < m_WorldAge - 40)
+ if (m_LastTimeUpdate < m_WorldAge - cTickTime(40))
{
BroadcastTimeUpdate();
- m_LastTimeUpdate = m_WorldAge;
+ m_LastTimeUpdate = std::chrono::duration_cast<cTickTimeLong>(m_WorldAge);
}
}
@@ -911,23 +905,23 @@ void cWorld::Tick(float a_Dt, int a_LastTickDurationMSec)
m_ChunkMap->Tick(a_Dt);
- TickClients(a_Dt);
+ TickClients(a_Dt.count());
TickQueuedBlocks();
TickQueuedTasks();
TickScheduledTasks();
- GetSimulatorManager()->Simulate(a_Dt);
+ GetSimulatorManager()->Simulate(a_Dt.count());
- TickWeather(a_Dt);
+ TickWeather(a_Dt.count());
m_ChunkMap->FastSetQueuedBlocks();
- if (m_WorldAge - m_LastSave > 60 * 5 * 20) // Save each 5 minutes
+ if (m_WorldAge - m_LastSave > std::chrono::minutes(5)) // Save each 5 minutes
{
SaveAllChunks();
}
- if (m_WorldAge - m_LastUnload > 10 * 20) // Unload every 10 seconds
+ if (m_WorldAge - m_LastUnload > std::chrono::minutes(5)) // Unload every 10 seconds
{
UnloadUnusedChunks();
}
@@ -973,7 +967,7 @@ void cWorld::TickWeather(float a_Dt)
-void cWorld::TickMobs(float a_Dt)
+void cWorld::TickMobs(std::chrono::milliseconds a_Dt)
{
// _X 2013_10_22: This is a quick fix for #283 - the world needs to be locked while ticking mobs
cWorld::cLock Lock(*this);
@@ -994,7 +988,7 @@ void cWorld::TickMobs(float a_Dt)
for (size_t i = 0; i < ARRAYCOUNT(AllFamilies); i++)
{
cMonster::eFamily Family = AllFamilies[i];
- int SpawnDelay = cMonster::GetSpawnDelay(Family);
+ cTickTime SpawnDelay = cTickTime(cMonster::GetSpawnDelay(Family));
if (
(m_LastSpawnMonster[Family] > m_WorldAge - SpawnDelay) || // Not reached the needed ticks before the next round
MobCensus.IsCapped(Family)
@@ -1002,7 +996,7 @@ void cWorld::TickMobs(float a_Dt)
{
continue;
}
- m_LastSpawnMonster[Family] = m_WorldAge;
+ m_LastSpawnMonster[Family] = std::chrono::duration_cast<cTickTimeLong>(m_WorldAge);
cMobSpawner Spawner(Family, m_AllowedMobs);
if (Spawner.CanSpawnAnything())
{
@@ -1066,7 +1060,7 @@ void cWorld::TickScheduledTasks(void)
// Move all the due tasks from m_ScheduledTasks into Tasks:
for (auto itr = m_ScheduledTasks.begin(); itr != m_ScheduledTasks.end();) // Cannot use range-basd for, we're modifying the container
{
- if ((*itr)->m_TargetTick < WorldAge)
+ if ((*itr)->m_TargetTick < std::chrono::duration_cast<cTickTimeLong>(WorldAge).count())
{
auto next = itr;
++next;
@@ -1141,7 +1135,7 @@ void cWorld::TickClients(float a_Dt)
void cWorld::UpdateSkyDarkness(void)
{
- int TempTime = (int)m_TimeOfDay;
+ int TempTime = std::chrono::duration_cast<cTickTime>(m_TimeOfDay).count();
if (TempTime <= TIME_SUNSET)
{
m_SkyDarkness = 0;
@@ -1422,14 +1416,15 @@ void cWorld::GrowTreeFromSapling(int a_X, int a_Y, int a_Z, NIBBLETYPE a_Sapling
{
cNoise Noise(m_Generator.GetSeed());
sSetBlockVector Logs, Other;
+ auto WorldAge = (int)(std::chrono::duration_cast<cTickTimeLong>(m_WorldAge).count() & 0xffffffff);
switch (a_SaplingMeta & 0x07)
{
- case E_META_SAPLING_APPLE: GetAppleTreeImage (a_X, a_Y, a_Z, Noise, (int)(m_WorldAge & 0xffffffff), Logs, Other); break;
- case E_META_SAPLING_BIRCH: GetBirchTreeImage (a_X, a_Y, a_Z, Noise, (int)(m_WorldAge & 0xffffffff), Logs, Other); break;
- case E_META_SAPLING_CONIFER: GetConiferTreeImage(a_X, a_Y, a_Z, Noise, (int)(m_WorldAge & 0xffffffff), Logs, Other); break;
- case E_META_SAPLING_JUNGLE: GetJungleTreeImage (a_X, a_Y, a_Z, Noise, (int)(m_WorldAge & 0xffffffff), Logs, Other); break;
- case E_META_SAPLING_ACACIA: GetAcaciaTreeImage (a_X, a_Y, a_Z, Noise, (int)(m_WorldAge & 0xffffffff), Logs, Other); break;
- case E_META_SAPLING_DARK_OAK: GetDarkoakTreeImage(a_X, a_Y, a_Z, Noise, (int)(m_WorldAge & 0xffffffff), Logs, Other); break;
+ case E_META_SAPLING_APPLE: GetAppleTreeImage (a_X, a_Y, a_Z, Noise, WorldAge, Logs, Other); break;
+ case E_META_SAPLING_BIRCH: GetBirchTreeImage (a_X, a_Y, a_Z, Noise, WorldAge, Logs, Other); break;
+ case E_META_SAPLING_CONIFER: GetConiferTreeImage(a_X, a_Y, a_Z, Noise, WorldAge, Logs, Other); break;
+ case E_META_SAPLING_JUNGLE: GetJungleTreeImage (a_X, a_Y, a_Z, Noise, WorldAge, Logs, Other); break;
+ case E_META_SAPLING_ACACIA: GetAcaciaTreeImage (a_X, a_Y, a_Z, Noise, WorldAge, Logs, Other); break;
+ case E_META_SAPLING_DARK_OAK: GetDarkoakTreeImage(a_X, a_Y, a_Z, Noise, WorldAge, Logs, Other); break;
}
Other.insert(Other.begin(), Logs.begin(), Logs.end());
Logs.clear();
@@ -1444,7 +1439,7 @@ void cWorld::GrowTreeByBiome(int a_X, int a_Y, int a_Z)
{
cNoise Noise(m_Generator.GetSeed());
sSetBlockVector Logs, Other;
- GetTreeImageByBiome(a_X, a_Y, a_Z, Noise, (int)(m_WorldAge & 0xffffffff), GetBiomeAt(a_X, a_Z), Logs, Other);
+ GetTreeImageByBiome(a_X, a_Y, a_Z, Noise, (int)(std::chrono::duration_cast<cTickTimeLong>(m_WorldAge).count() & 0xffffffff), GetBiomeAt(a_X, a_Z), Logs, Other);
Other.insert(Other.begin(), Logs.begin(), Logs.end());
Logs.clear();
GrowTreeImage(Other);
@@ -2405,7 +2400,7 @@ void cWorld::BroadcastTimeUpdate(const cClientHandle * a_Exclude)
{
continue;
}
- ch->SendTimeUpdate(m_WorldAge, m_TimeOfDay, m_IsDaylightCycleEnabled);
+ ch->SendTimeUpdate(std::chrono::duration_cast<cTickTimeLong>(m_WorldAge).count(), std::chrono::duration_cast<cTickTimeLong>(m_TimeOfDay).count(), m_IsDaylightCycleEnabled);
}
}
@@ -2607,7 +2602,7 @@ bool cWorld::HasChunkAnyClients(int a_ChunkX, int a_ChunkZ) const
void cWorld::UnloadUnusedChunks(void)
{
- m_LastUnload = m_WorldAge;
+ m_LastUnload = std::chrono::duration_cast<cTickTimeLong>(m_WorldAge);
m_ChunkMap->UnloadUnusedChunks();
}
@@ -3083,7 +3078,7 @@ bool cWorld::ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunk
void cWorld::SaveAllChunks(void)
{
- m_LastSave = m_WorldAge;
+ m_LastSave = std::chrono::duration_cast<cTickTimeLong>(m_WorldAge);
m_ChunkMap->SaveAllChunks();
}
@@ -3112,7 +3107,7 @@ void cWorld::QueueTask(std::unique_ptr<cTask> a_Task)
void cWorld::ScheduleTask(int a_DelayTicks, cTask * a_Task)
{
- Int64 TargetTick = a_DelayTicks + m_WorldAge;
+ Int64 TargetTick = a_DelayTicks + std::chrono::duration_cast<cTickTimeLong>(m_WorldAge).count();
// Insert the task into the list of scheduled tasks, ordered by its target tick
cCSLock Lock(m_CSScheduledTasks);
diff --git a/src/World.h b/src/World.h
index 2ee33375f..4e5c9bceb 100644
--- a/src/World.h
+++ b/src/World.h
@@ -157,8 +157,8 @@ public:
BroadcastTimeUpdate();
}
- virtual Int64 GetWorldAge (void) const override { return m_WorldAge; }
- virtual int GetTimeOfDay(void) const override { return m_TimeOfDay; }
+ virtual Int64 GetWorldAge (void) const override { return std::chrono::duration_cast<cTickTimeLong>(m_WorldAge).count(); }
+ virtual int GetTimeOfDay(void) const override { return std::chrono::duration_cast<cTickTime>(m_TimeOfDay).count(); }
void SetTicksUntilWeatherChange(int a_WeatherInterval)
{
@@ -167,8 +167,7 @@ public:
virtual void SetTimeOfDay(int a_TimeOfDay) override
{
- m_TimeOfDay = a_TimeOfDay;
- m_TimeOfDaySecs = (double)a_TimeOfDay / 20.0;
+ m_TimeOfDay = cTickTime(a_TimeOfDay);
UpdateSkyDarkness();
BroadcastTimeUpdate();
}
@@ -913,15 +912,14 @@ private:
bool m_BroadcastDeathMessages;
bool m_BroadcastAchievementMessages;
- bool m_IsDaylightCycleEnabled;
- double m_WorldAgeSecs; // World age, in seconds. Is only incremented, cannot be set by plugins.
- double m_TimeOfDaySecs; // Time of day in seconds. Can be adjusted. Is wrapped to zero each day.
- Int64 m_WorldAge; // World age in ticks, calculated off of m_WorldAgeSecs
- int m_TimeOfDay; // Time in ticks, calculated off of m_TimeOfDaySecs
- Int64 m_LastTimeUpdate; // The tick in which the last time update has been sent.
- Int64 m_LastUnload; // The last WorldAge (in ticks) in which unloading was triggerred
- Int64 m_LastSave; // The last WorldAge (in ticks) in which save-all was triggerred
- std::map<cMonster::eFamily, Int64> m_LastSpawnMonster; // The last WorldAge (in ticks) in which a monster was spawned (for each megatype of monster) // MG TODO : find a way to optimize without creating unmaintenability (if mob IDs are becoming unrowed)
+ bool m_IsDaylightCycleEnabled;
+ // std::chrono::milliseconds is guaranteed to be good for 292 years by the standard.
+ std::chrono::milliseconds m_WorldAge;
+ std::chrono::milliseconds m_TimeOfDay;
+ cTickTimeLong m_LastTimeUpdate; // The tick in which the last time update has been sent.
+ cTickTimeLong m_LastUnload; // The last WorldAge (in ticks) in which unloading was triggerred
+ cTickTimeLong m_LastSave; // The last WorldAge (in ticks) in which save-all was triggerred
+ std::map<cMonster::eFamily, cTickTimeLong> m_LastSpawnMonster; // The last WorldAge (in ticks) in which a monster was spawned (for each megatype of monster) // MG TODO : find a way to optimize without creating unmaintenability (if mob IDs are becoming unrowed)
NIBBLETYPE m_SkyDarkness;
@@ -1051,13 +1049,13 @@ private:
cWorld(const AString & a_WorldName, eDimension a_Dimension = dimOverworld, const AString & a_OverworldName = "");
virtual ~cWorld();
- void Tick(float a_Dt, int a_LastTickDurationMSec);
+ void Tick(std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec);
/** Handles the weather in each tick */
void TickWeather(float a_Dt);
/** Handles the mob spawning/moving/destroying each tick */
- void TickMobs(float a_Dt);
+ void TickMobs(std::chrono::milliseconds a_Dt);
/** Executes all tasks queued onto the tick thread */
void TickQueuedTasks(void);