From db3466dbe885f27b87ceca0a4bb115169f844a0c Mon Sep 17 00:00:00 2001 From: gregorycu Date: Wed, 14 Jan 2015 01:19:54 +1100 Subject: Water fixes Change must_reflow to a deque Add overload for MapBlock::raiseModified that takes a const char*. This is a speed improvement. Comment out unused variable Optimisations to block offset calculations --- src/mapblock.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/mapblock.h') diff --git a/src/mapblock.h b/src/mapblock.h index 76c82c083..5cf2bc801 100644 --- a/src/mapblock.h +++ b/src/mapblock.h @@ -166,6 +166,29 @@ public: } } } + void raiseModified(u32 mod, const char *reason) + { + if (mod > m_modified){ + m_modified = mod; + m_modified_reason = reason; + m_modified_reason_too_long = false; + + if (m_modified >= MOD_STATE_WRITE_AT_UNLOAD){ + m_disk_timestamp = m_timestamp; + } + } + else if (mod == m_modified){ + if (!m_modified_reason_too_long){ + if (m_modified_reason.size() < 40) + m_modified_reason += ", " + std::string(reason); + else{ + m_modified_reason += "..."; + m_modified_reason_too_long = true; + } + } + } + } + u32 getModified() { return m_modified; @@ -619,6 +642,16 @@ inline s16 getNodeBlockY(s16 y) return getContainerPos(y, MAP_BLOCKSIZE); } +inline void getNodeBlockPosWithOffset(const v3s16 &p, v3s16 &block, v3s16 &offset) +{ + getContainerPosWithOffset(p, MAP_BLOCKSIZE, block, offset); +} + +inline void getNodeSectorPosWithOffset(const v2s16 &p, v2s16 &block, v2s16 &offset) +{ + getContainerPosWithOffset(p, MAP_BLOCKSIZE, block, offset); +} + /* Get a quick string to describe what a block actually contains */ -- cgit v1.2.3