diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 782378c..8c6fedc 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -1237,7 +1237,7 @@ Entity definition (register_entity) initial_properties = , - on_activate = function(self, staticdata), + on_activate = function(self, staticdata, dtime_s), on_step = function(self, dtime), on_punch = function(self, hitter), on_rightclick = function(self, clicker), diff --git a/src/content_sao.cpp b/src/content_sao.cpp index 843ab29..7526e03 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -376,9 +376,9 @@ LuaEntitySAO::~LuaEntitySAO() } } -void LuaEntitySAO::addedToEnvironment() +void LuaEntitySAO::addedToEnvironment(u32 dtime_s) { - ServerActiveObject::addedToEnvironment(); + ServerActiveObject::addedToEnvironment(dtime_s); // Create entity from name lua_State *L = m_env->getLua(); @@ -390,7 +390,7 @@ void LuaEntitySAO::addedToEnvironment() // Initialize HP from properties m_hp = m_prop.hp_max; // Activate entity, supplying serialized state - scriptapi_luaentity_activate(L, m_id, m_init_state.c_str()); + scriptapi_luaentity_activate(L, m_id, m_init_state.c_str(), dtime_s); } } @@ -805,9 +805,9 @@ std::string PlayerSAO::getDescription() } // Called after id has been set and has been inserted in environment -void PlayerSAO::addedToEnvironment() +void PlayerSAO::addedToEnvironment(u32 dtime_s) { - ServerActiveObject::addedToEnvironment(); + ServerActiveObject::addedToEnvironment(dtime_s); ServerActiveObject::setBasePosition(m_player->getPosition()); m_player->setPlayerSAO(this); m_player->peer_id = m_peer_id; diff --git a/src/content_sao.h b/src/content_sao.h index ff427ba..05c77e2 100644 --- a/src/content_sao.h +++ b/src/content_sao.h @@ -43,7 +43,7 @@ public: { return ACTIVEOBJECT_TYPE_LUAENTITY; } u8 getSendType() const { return ACTIVEOBJECT_TYPE_GENERIC; } - virtual void addedToEnvironment(); + virtual void addedToEnvironment(u32 dtime_s); static ServerActiveObject* create(ServerEnvironment *env, v3f pos, const std::string &data); void step(float dtime, bool send_recommended); @@ -118,7 +118,7 @@ public: Active object <-> environment interface */ - void addedToEnvironment(); + void addedToEnvironment(u32 dtime_s); void removingFromEnvironment(); bool isStaticAllowed() const; bool unlimitedTransferDistance() const; diff --git a/src/environment.cpp b/src/environment.cpp index 10ebd41..4abba63 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -790,7 +790,7 @@ void ServerEnvironment::activateBlock(MapBlock *block, u32 additional_dtime) < elapsed_timers = @@ -1249,7 +1249,7 @@ u16 getFreeServerActiveObjectId( u16 ServerEnvironment::addActiveObject(ServerActiveObject *object) { assert(object); - u16 id = addActiveObjectRaw(object, true); + u16 id = addActiveObjectRaw(object, true, 0); return id; } @@ -1408,7 +1408,7 @@ ActiveObjectMessage ServerEnvironment::getActiveObjectMessage() */ u16 ServerEnvironment::addActiveObjectRaw(ServerActiveObject *object, - bool set_changed) + bool set_changed, u32 dtime_s) { assert(object); if(object->getId() == 0){ @@ -1448,7 +1448,7 @@ u16 ServerEnvironment::addActiveObjectRaw(ServerActiveObject *object, // Register reference in scripting api (must be done before post-init) scriptapi_add_object_reference(m_lua, object); // Post-initialize object - object->addedToEnvironment(); + object->addedToEnvironment(dtime_s); // Add static data to block if(object->isStaticAllowed()) @@ -1585,7 +1585,7 @@ static void print_hexdump(std::ostream &o, const std::string &data) /* Convert stored objects from blocks near the players to active. */ -void ServerEnvironment::activateObjects(MapBlock *block) +void ServerEnvironment::activateObjects(MapBlock *block, u32 dtime_s) { if(block==NULL) return; @@ -1609,7 +1609,7 @@ void ServerEnvironment::activateObjects(MapBlock *block) "large amount of objects"); return; } - // A list for objects that couldn't be converted to static for some + // A list for objects that couldn't be converted to active for some // reason. They will be stored back. core::list new_stored; // Loop through stored static objects @@ -1639,7 +1639,7 @@ void ServerEnvironment::activateObjects(MapBlock *block) <<"activated static object pos="<