mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-17 17:08:39 +00:00
Protect per-player detached inventory actions
This commit is contained in:
parent
67be50b706
commit
41beb74ef7
3 changed files with 18 additions and 1 deletions
|
@ -168,6 +168,18 @@ bool ServerInventoryManager::removeDetachedInventory(const std::string &name)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ServerInventoryManager::checkDetachedInventoryAccess(
|
||||
const InventoryLocation &loc, const std::string &player) const
|
||||
{
|
||||
SANITY_CHECK(loc.type == InventoryLocation::DETACHED);
|
||||
|
||||
const auto &inv_it = m_detached_inventories.find(loc.name);
|
||||
if (inv_it == m_detached_inventories.end())
|
||||
return false;
|
||||
|
||||
return inv_it->second.owner.empty() || inv_it->second.owner == player;
|
||||
}
|
||||
|
||||
void ServerInventoryManager::sendDetachedInventories(const std::string &peer_name,
|
||||
bool incremental,
|
||||
std::function<void(const std::string &, Inventory *)> apply_cb)
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
Inventory *createDetachedInventory(const std::string &name, IItemDefManager *idef,
|
||||
const std::string &player = "");
|
||||
bool removeDetachedInventory(const std::string &name);
|
||||
bool checkDetachedInventoryAccess(const InventoryLocation &loc, const std::string &player) const;
|
||||
|
||||
void sendDetachedInventories(const std::string &peer_name, bool incremental,
|
||||
std::function<void(const std::string &, Inventory *)> apply_cb);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue