X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fnodetimer.h;h=40e54ccc569221e5e679965423d63ad5a38561ab;hb=8a99c8c94a40640c7c337278277f5c027e96f3cb;hp=0fd43b2a886598cb00a188873718c907e39ca670;hpb=559dd9946988cd35a7c26bcafe7d0f8c42dc547a;p=dragonfireclient.git diff --git a/src/nodetimer.h b/src/nodetimer.h index 0fd43b2a8..40e54ccc5 100644 --- a/src/nodetimer.h +++ b/src/nodetimer.h @@ -17,8 +17,7 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef NODETIMER_HEADER -#define NODETIMER_HEADER +#pragma once #include "irr_v3d.h" #include @@ -36,18 +35,18 @@ with this program; if not, write to the Free Software Foundation, Inc., class NodeTimer { public: - NodeTimer(): timeout(0.), elapsed(0.) {} + NodeTimer() = default; NodeTimer(const v3s16 &position_): - timeout(0.), elapsed(0.), position(position_) {} + position(position_) {} NodeTimer(f32 timeout_, f32 elapsed_, v3s16 position_): timeout(timeout_), elapsed(elapsed_), position(position_) {} - ~NodeTimer() {} - + ~NodeTimer() = default; + void serialize(std::ostream &os) const; void deSerialize(std::istream &is); - - f32 timeout; - f32 elapsed; + + f32 timeout = 0.0f; + f32 elapsed = 0.0f; v3s16 position; }; @@ -58,12 +57,12 @@ class NodeTimer class NodeTimerList { public: - NodeTimerList(): m_next_trigger_time(-1.), m_time(0.) {} - ~NodeTimerList() {} - + NodeTimerList() = default; + ~NodeTimerList() = default; + void serialize(std::ostream &os, u8 map_format_version) const; void deSerialize(std::istream &is, u8 map_format_version); - + // Get timer NodeTimer get(const v3s16 &p) { std::map::iterator>::iterator n = @@ -118,19 +117,12 @@ class NodeTimerList m_next_trigger_time = -1.; } - inline double getNextTriggerTime() { - return m_next_trigger_time; - } - // Move forward in time, returns elapsed timers std::vector step(float dtime); private: std::multimap m_timers; std::map::iterator> m_iterators; - double m_next_trigger_time; - double m_time; + double m_next_trigger_time = -1.0; + double m_time = 0.0; }; - -#endif -