diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-04-04 15:13:19 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-04-04 15:13:19 +0300 |
commit | 4a92df6ff021f1bfa645f97fd551c648d1ef8e3b (patch) | |
tree | 6a1d12a56a2a57dbd84e3e660241916f3e1a2fe0 /src/client.cpp | |
parent | 9e683fff50ba4fef407613adf8407b31adca4596 (diff) | |
download | minetest-4a92df6ff021f1bfa645f97fd551c648d1ef8e3b.tar.gz minetest-4a92df6ff021f1bfa645f97fd551c648d1ef8e3b.tar.bz2 minetest-4a92df6ff021f1bfa645f97fd551c648d1ef8e3b.zip |
Chests work now!
Diffstat (limited to 'src/client.cpp')
-rw-r--r-- | src/client.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/client.cpp b/src/client.cpp index 2fb14cb68..ae0e027c2 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -106,6 +106,9 @@ Client::Client( player->updateName(playername); m_env.addPlayer(player); + + // Initialize player in the inventory context + m_inventory_context.current_player = player; } } @@ -1862,6 +1865,44 @@ void Client::getLocalInventory(Inventory &dst) dst = player->inventory; } +InventoryContext *Client::getInventoryContext() +{ + return &m_inventory_context; +} + +Inventory* Client::getInventory(InventoryContext *c, std::string id) +{ + if(id == "current_player") + { + assert(c->current_player); + return &(c->current_player->inventory); + } + + Strfnd fn(id); + std::string id0 = fn.next(":"); + + if(id0 == "nodemeta") + { + v3s16 p; + p.X = stoi(fn.next(",")); + p.Y = stoi(fn.next(",")); + p.Z = stoi(fn.next(",")); + NodeMetadata* meta = getNodeMetadata(p); + if(meta) + return meta->getInventory(); + dstream<<"nodemeta at ("<<p.X<<","<<p.Y<<","<<p.Z<<"): " + <<"no metadata found"<<std::endl; + return NULL; + } + + dstream<<__FUNCTION_NAME<<": unknown id "<<id<<std::endl; + return NULL; +} +void Client::inventoryAction(InventoryAction *a) +{ + sendInventoryAction(a); +} + MapBlockObject * Client::getSelectedObject( f32 max_d, v3f from_pos_f_on_map, |