obj->m_removed = true;
continue;
}
+
+ // Tell the object about removal
+ obj->removingFromEnvironment();
// Deregister in scripting api
scriptapi_rm_object_reference(m_lua, obj);
+
// Delete active object
delete obj;
// Id to be removed from m_active_objects
if(obj->m_known_by_count > 0)
continue;
+ // Tell the object about removal
+ obj->removingFromEnvironment();
// Deregister in scripting api
scriptapi_rm_object_reference(m_lua, obj);
<<"object id="<<id<<" is not known by clients"
<<"; deleting"<<std::endl;
+ // Tell the object about removal
+ obj->removingFromEnvironment();
// Deregister in scripting api
scriptapi_rm_object_reference(m_lua, obj);
{
}
-void ServerActiveObject::addedToEnvironment()
-{
-}
-
ServerActiveObject* ServerActiveObject::create(u8 type,
ServerEnvironment *env, u16 id, v3f pos,
const std::string &data)
ServerActiveObject(ServerEnvironment *env, v3f pos);
virtual ~ServerActiveObject();
- // Call after id has been set and has been inserted in environment
- virtual void addedToEnvironment();
+ // Called after id has been set and has been inserted in environment
+ virtual void addedToEnvironment(){};
+ // Called before removing from environment
+ virtual void removingFromEnvironment(){};
// Create a certain type of ServerActiveObject
static ServerActiveObject* create(u8 type,
the data is the static form)
*/
virtual std::string getStaticData(){return "";}
+ /*
+ Return false in here to never save and instead remove object
+ on unload. getStaticData() will not be called in that case.
+ */
+ virtual bool isStaticAllowed(){return true;}
virtual void punch(ServerActiveObject *puncher){}
virtual void rightClick(ServerActiveObject *clicker){}