summaryrefslogtreecommitdiff
path: root/src/client.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-12-06 15:21:56 +0200
committerPerttu Ahola <celeron55@gmail.com>2012-01-02 01:49:38 +0200
commit103173fc9b4fcb4c0fded2a93d5cbb8f0bea896e (patch)
tree416a253ff37aeb5944781dd1288c5afa7483d799 /src/client.cpp
parent70ed371d0cd532da8efc5acbd41a20e9a373b811 (diff)
downloadminetest-103173fc9b4fcb4c0fded2a93d5cbb8f0bea896e.tar.gz
minetest-103173fc9b4fcb4c0fded2a93d5cbb8f0bea896e.tar.bz2
minetest-103173fc9b4fcb4c0fded2a93d5cbb8f0bea896e.zip
Add InvRef and InvStack (currently untested and unusable)
Diffstat (limited to 'src/client.cpp')
-rw-r--r--src/client.cpp29
1 files changed, 29 insertions, 0 deletions
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 "<<id<<std::endl;
return NULL;
}
+#endif
void Client::inventoryAction(InventoryAction *a)
{
sendInventoryAction(a);