From 2a9664d6ca8aa9eb4f554301e4d9b0ec33b465ce Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 11 Jan 2015 21:12:26 +0000 Subject: Initial convertion of a_Dt to std::chrono also refactored cWorld::m_WorldAge and cWorld::m_TimeOfDay --- src/Entities/Pickup.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Entities/Pickup.cpp') 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); -- cgit v1.2.3 From 05c40db060809612e6d0bb3bee596c4c95ce758d Mon Sep 17 00:00:00 2001 From: Tycho Date: Fri, 16 Jan 2015 13:49:22 +0000 Subject: Converted cPickupEntity to std::chrono --- src/Entities/Pickup.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/Entities/Pickup.cpp') diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp index accb42a63..9f2609894 100644 --- a/src/Entities/Pickup.cpp +++ b/src/Entities/Pickup.cpp @@ -86,7 +86,7 @@ protected: cPickup::cPickup(double a_PosX, double a_PosY, double a_PosZ, const cItem & a_Item, bool IsPlayerCreated, float a_SpeedX /* = 0.f */, float a_SpeedY /* = 0.f */, float a_SpeedZ /* = 0.f */) : cEntity(etPickup, a_PosX, a_PosY, a_PosZ, 0.2, 0.2) - , m_Timer(0.f) + , m_Timer(0) , m_Item(a_Item) , m_bCollected(false) , m_bIsPlayerCreated(IsPlayerCreated) @@ -115,7 +115,7 @@ 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.count(); + m_Timer += a_Dt; if (!m_bCollected) { @@ -141,9 +141,9 @@ void cPickup::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) ) { m_bCollected = true; - m_Timer = 0; // We have to reset the timer. - m_Timer += a_Dt.count(); // In case we have to destroy the pickup in the same tick. - if (m_Timer > 500.f) + m_Timer = std::chrono::milliseconds(0); // We have to reset the timer. + m_Timer += a_Dt; // In case we have to destroy the pickup in the same tick. + if (m_Timer > std::chrono::milliseconds(500)) { Destroy(true); return; @@ -167,14 +167,14 @@ void cPickup::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) } else { - if (m_Timer > 500.f) // 0.5 second + if (m_Timer > std::chrono::milliseconds(500)) // 0.5 second { Destroy(true); return; } } - if (m_Timer > 1000 * 60 * 5) // 5 minutes + if (m_Timer > std::chrono::minutes(5)) // 5 minutes { Destroy(true); return; @@ -200,7 +200,7 @@ bool cPickup::CollectedBy(cPlayer & a_Dest) } // Two seconds if player created the pickup (vomiting), half a second if anything else - if (m_Timer < (m_bIsPlayerCreated ? 2000.f : 500.f)) + if (m_Timer < (m_bIsPlayerCreated ? std::chrono::seconds(2) : std::chrono::milliseconds(500))) { // LOG("Pickup %d cannot be collected by \"%s\", because it is not old enough.", m_UniqueID, a_Dest->GetName().c_str()); return false; // Not old enough @@ -234,7 +234,7 @@ bool cPickup::CollectedBy(cPlayer & a_Dest) // All of the pickup has been collected, schedule the pickup for destroying m_bCollected = true; } - m_Timer = 0; + m_Timer = std::chrono::milliseconds(0); return true; } -- cgit v1.2.3