diff options
author | Ekdohibs <nathanael.courant@laposte.net> | 2016-03-21 12:58:52 +0100 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2016-06-11 23:35:17 +0100 |
commit | 559dd9946988cd35a7c26bcafe7d0f8c42dc547a (patch) | |
tree | fb898f7202095e2bdb996820370dd139b82b30ee /src/map.cpp | |
parent | 27aff22a9b68044d3ea51db731597834336effa3 (diff) | |
download | minetest-559dd9946988cd35a7c26bcafe7d0f8c42dc547a.tar.gz minetest-559dd9946988cd35a7c26bcafe7d0f8c42dc547a.tar.bz2 minetest-559dd9946988cd35a7c26bcafe7d0f8c42dc547a.zip |
Make node timers more efficient
Diffstat (limited to 'src/map.cpp')
-rw-r--r-- | src/map.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/map.cpp b/src/map.cpp index 03daf4fa8..a1f2086ce 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2087,11 +2087,13 @@ NodeTimer Map::getNodeTimer(v3s16 p) return NodeTimer(); } NodeTimer t = block->m_node_timers.get(p_rel); - return t; + NodeTimer nt(t.timeout, t.elapsed, p); + return nt; } -void Map::setNodeTimer(v3s16 p, NodeTimer t) +void Map::setNodeTimer(const NodeTimer &t) { + v3s16 p = t.position; v3s16 blockpos = getNodeBlockPos(p); v3s16 p_rel = p - blockpos*MAP_BLOCKSIZE; MapBlock *block = getBlockNoCreateNoEx(blockpos); @@ -2105,7 +2107,8 @@ void Map::setNodeTimer(v3s16 p, NodeTimer t) <<std::endl; return; } - block->m_node_timers.set(p_rel, t); + NodeTimer nt(t.timeout, t.elapsed, p_rel); + block->m_node_timers.set(nt); } void Map::removeNodeTimer(v3s16 p) |