diff options
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, |