fixes node timer bug (fixes #407).
authorJürgen Doser <jurgen.doser@gmail.com>
Fri, 11 Jan 2013 17:52:00 +0000 (18:52 +0100)
committerJürgen Doser <jurgen.doser@gmail.com>
Fri, 11 Jan 2013 17:59:27 +0000 (18:59 +0100)
Previously, when a block was activated, on_timer callbacks where
called with the relative position of the node inside the block,
instead of the absolute position of the node.

src/environment.cpp

index 020d2b43377f7c80ef27b52aa720a485d7c4866e..3f94484fe41610c69c6652e8ca1e7b16074d5540 100644 (file)
@@ -804,7 +804,8 @@ void ServerEnvironment::activateBlock(MapBlock *block, u32 additional_dtime)
                                i = elapsed_timers.begin();
                                i != elapsed_timers.end(); i++){
                        n = block->getNodeNoEx(i->first);
-                       if(scriptapi_node_on_timer(m_lua,i->first,n,i->second.elapsed))
+                       v3s16 p = i->first + block->getPosRelative();
+                       if(scriptapi_node_on_timer(m_lua,p,n,i->second.elapsed))
                                block->setNodeTimer(i->first,NodeTimer(i->second.timeout,0));
                }
        }