+ const bool player_has_interact = checkPriv(player->getName(), "interact");
+
+ auto check_inv_access = [player, player_has_interact] (
+ const InventoryLocation &loc) -> bool {
+ if (loc.type == InventoryLocation::CURRENT_PLAYER)
+ return false; // Only used internally on the client, never sent
+ if (loc.type == InventoryLocation::PLAYER) {
+ // Allow access to own inventory in all cases
+ return loc.name == player->getName();
+ }
+
+ if (!player_has_interact) {
+ infostream << "Cannot modify foreign inventory: "
+ << "No interact privilege" << std::endl;
+ return false;
+ }
+ return true;
+ };
+