Add different automatic profiler graph drawing style for relative-ish plots
[oweals/minetest.git] / src / serverobject.cpp
index 8acb35f6db84fefd601d03e8f4496dbb050f5c2c..4d7f1924359bdee0889942620b8378dd5550ddcd 100644 (file)
@@ -21,10 +21,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include <fstream>
 #include "inventory.h"
 
-core::map<u16, ServerActiveObject::Factory> ServerActiveObject::m_types;
-
-ServerActiveObject::ServerActiveObject(ServerEnvironment *env, u16 id, v3f pos):
-       ActiveObject(id),
+ServerActiveObject::ServerActiveObject(ServerEnvironment *env, v3f pos):
+       ActiveObject(0),
        m_known_by_count(0),
        m_removed(false),
        m_pending_deactivation(false),
@@ -55,7 +53,7 @@ ServerActiveObject* ServerActiveObject::create(u8 type,
        }
 
        Factory f = n->getValue();
-       ServerActiveObject *object = (*f)(env, id, pos, data);
+       ServerActiveObject *object = (*f)(env, pos, data);
        return object;
 }
 
@@ -68,5 +66,31 @@ void ServerActiveObject::registerType(u16 type, Factory f)
        m_types.insert(type, f);
 }
 
+ItemStack ServerActiveObject::getWieldedItem() const
+{
+       const Inventory *inv = getInventory();
+       if(inv)
+       {
+               const InventoryList *list = inv->getList(getWieldList());
+               if(list)
+                       return list->getItem(getWieldIndex());
+       }
+       return ItemStack();
+}
 
+bool ServerActiveObject::setWieldedItem(const ItemStack &item)
+{
+       Inventory *inv = getInventory();
+       if(inv)
+       {
+               InventoryList *list = inv->getList(getWieldList());
+               if (list)
+               {
+                       list->changeItem(getWieldIndex(), item);
+                       setInventoryModified();
+                       return true;
+               }
+       }
+       return false;
+}