From 9d5b458479a4eac14acb5af28f51ad23432264ab Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Thu, 17 Nov 2011 02:28:46 +0200 Subject: Crafting definition in scripts --- src/server.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'src/server.cpp') diff --git a/src/server.cpp b/src/server.cpp index c01b5050d..894c3d362 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -43,6 +43,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "scriptapi.h" #include "nodedef.h" #include "tooldef.h" +#include "craftdef.h" #define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")" @@ -988,6 +989,7 @@ Server::Server( m_lua(NULL), m_toolmgr(createToolDefManager()), m_nodedef(createNodeDefManager()), + m_craftdef(createCraftDefManager()), m_thread(this), m_emergethread(this), m_time_counter(0), @@ -4332,14 +4334,19 @@ void Server::UpdateCrafting(u16 peer_id) } if(clist && rlist && player->craftresult_is_preview) { - InventoryItem *items[9]; - for(u16 i=0; i<9; i++) - { - items[i] = clist->getItem(i); + // Get result of crafting grid + + std::vector items; + for(u16 i=0; i<9; i++){ + if(clist->getItem(i) == NULL) + items.push_back(NULL); + else + items.push_back(clist->getItem(i)->clone()); } + CraftPointerInput cpi(3, items); - // Get result of crafting grid - InventoryItem *result = craft_get_result(items, this); + InventoryItem *result = m_craftdef->getCraftResult(cpi, this); + //InventoryItem *result = craft_get_result(items, this); if(result) rlist->addItem(result); } @@ -4424,6 +4431,10 @@ INodeDefManager* Server::getNodeDefManager() { return m_nodedef; } +ICraftDefManager* Server::getCraftDefManager() +{ + return m_craftdef; +} ITextureSource* Server::getTextureSource() { return NULL; @@ -4441,6 +4452,10 @@ IWritableNodeDefManager* Server::getWritableNodeDefManager() { return m_nodedef; } +IWritableCraftDefManager* Server::getWritableCraftDefManager() +{ + return m_craftdef; +} v3f findSpawnPos(ServerMap &map) { -- cgit v1.2.3