diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-11-14 00:19:48 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-11-29 19:13:41 +0200 |
commit | abceeee92f99b84ebb79968269835a4f509bfb90 (patch) | |
tree | 669edeca68fae4eb086ac4e4c1846b55d3aa779d /src/content_sao.cpp | |
parent | 5fc791ac9a15ea6f234ca2d23041c83679255746 (diff) | |
download | minetest-abceeee92f99b84ebb79968269835a4f509bfb90.tar.gz minetest-abceeee92f99b84ebb79968269835a4f509bfb90.tar.bz2 minetest-abceeee92f99b84ebb79968269835a4f509bfb90.zip |
Create framework for getting rid of global definitions of node/tool/item/whatever types
Diffstat (limited to 'src/content_sao.cpp')
-rw-r--r-- | src/content_sao.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/content_sao.cpp b/src/content_sao.cpp index 1096ac116..9c48e0707 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "collision.h" #include "environment.h" #include "settings.h" +#include "main.h" // For g_profiler #include "profiler.h" core::map<u16, ServerActiveObject::Factory> ServerActiveObject::m_types; @@ -223,7 +224,8 @@ InventoryItem * ItemSAO::createInventoryItem() { try{ std::istringstream is(m_inventorystring, std::ios_base::binary); - InventoryItem *item = InventoryItem::deSerialize(is); + IGameDef *gamedef = m_env->getGameDef(); + InventoryItem *item = InventoryItem::deSerialize(is, gamedef); infostream<<__FUNCTION_NAME<<": m_inventorystring=\"" <<m_inventorystring<<"\" -> item="<<item <<std::endl; @@ -448,7 +450,8 @@ std::string RatSAO::getStaticData() void RatSAO::punch(ServerActiveObject *puncher) { std::istringstream is("CraftItem rat 1", std::ios_base::binary); - InventoryItem *item = InventoryItem::deSerialize(is); + IGameDef *gamedef = m_env->getGameDef(); + InventoryItem *item = InventoryItem::deSerialize(is, gamedef); bool fits = puncher->addToInventory(item); if(fits) m_removed = true; @@ -932,7 +935,8 @@ std::string FireflySAO::getStaticData() InventoryItem* FireflySAO::createPickedUpItem() { std::istringstream is("CraftItem firefly 1", std::ios_base::binary); - InventoryItem *item = InventoryItem::deSerialize(is); + IGameDef *gamedef = m_env->getGameDef(); + InventoryItem *item = InventoryItem::deSerialize(is, gamedef); return item; } @@ -1563,13 +1567,14 @@ LuaEntitySAO::~LuaEntitySAO() delete m_prop; } -void LuaEntitySAO::addedToEnvironment(u16 id) +void LuaEntitySAO::addedToEnvironment() { - ServerActiveObject::addedToEnvironment(id); + ServerActiveObject::addedToEnvironment(); // Create entity from name and state lua_State *L = m_env->getLua(); - m_registered = scriptapi_luaentity_add(L, id, m_init_name.c_str(), m_init_state.c_str()); + m_registered = scriptapi_luaentity_add(L, m_id, m_init_name.c_str(), + m_init_state.c_str()); if(m_registered){ // Get properties @@ -1660,7 +1665,8 @@ std::string LuaEntitySAO::getStaticData() InventoryItem* LuaEntitySAO::createPickedUpItem() { std::istringstream is("CraftItem testobject1 1", std::ios_base::binary); - InventoryItem *item = InventoryItem::deSerialize(is); + IGameDef *gamedef = m_env->getGameDef(); + InventoryItem *item = InventoryItem::deSerialize(is, gamedef); return item; } |