From 103173fc9b4fcb4c0fded2a93d5cbb8f0bea896e Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Tue, 6 Dec 2011 15:21:56 +0200 Subject: Add InvRef and InvStack (currently untested and unusable) --- src/client.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/client.cpp') diff --git a/src/client.cpp b/src/client.cpp index d092c6a10..cfdc713db 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1782,6 +1782,34 @@ InventoryContext *Client::getInventoryContext() return &m_inventory_context; } +Inventory* Client::getInventory(const InventoryLocation &loc) +{ + switch(loc.type){ + case InventoryLocation::UNDEFINED: + {} + break; + case InventoryLocation::PLAYER: + { + Player *player = m_env.getPlayer(loc.name.c_str()); + if(!player) + return NULL; + return &player->inventory; + } + break; + case InventoryLocation::NODEMETA: + { + NodeMetadata *meta = m_env.getMap().getNodeMetadata(loc.p); + if(!meta) + return NULL; + return meta->getInventory(); + } + break; + default: + assert(0); + } + return NULL; +} +#if 0 Inventory* Client::getInventory(InventoryContext *c, std::string id) { if(id == "current_player") @@ -1810,6 +1838,7 @@ Inventory* Client::getInventory(InventoryContext *c, std::string id) infostream<<__FUNCTION_NAME<<": unknown id "<