aboutsummaryrefslogtreecommitdiff
path: root/src/server.cpp
diff options
context:
space:
mode:
authordarkrose <lisa@ltmnet.com>2011-09-22 19:11:48 +1000
committerdarkrose <lisa@ltmnet.com>2011-09-22 19:11:48 +1000
commit582e450bad08006dff141216351b81d3eb9270b7 (patch)
tree0c76a61f5e36f8e4414d220637ff90eacde4eb86 /src/server.cpp
parentae6d83a41ed958b65ec7f6584d7b042ae6a6e51f (diff)
downloadminetest-582e450bad08006dff141216351b81d3eb9270b7.tar.gz
minetest-582e450bad08006dff141216351b81d3eb9270b7.tar.bz2
minetest-582e450bad08006dff141216351b81d3eb9270b7.zip
added locking chests - clean patch
Diffstat (limited to 'src/server.cpp')
-rw-r--r--src/server.cpp42
1 files changed, 41 insertions, 1 deletions
diff --git a/src/server.cpp b/src/server.cpp
index 14d8942cb..689a2b538 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -2873,7 +2873,8 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
{
MapEditEventIgnorer ign(&m_ignore_map_edit_events);
- m_env.getMap().addNodeAndUpdate(p_over, n, modified_blocks);
+ std::string p_name = std::string(player->getName());
+ m_env.getMap().addNodeAndUpdate(p_over, n, modified_blocks, p_name);
}
/*
Set blocks not sent to far players
@@ -3200,7 +3201,46 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
}
// Disallow moving items if not allowed to build
else if((getPlayerPrivs(player) & PRIV_BUILD) == 0)
+ {
return;
+ }
+ // if it's a locking chest, only allow the owner or server admins to move items
+ else if (ma->from_inv != "current_player" && (getPlayerPrivs(player) & PRIV_SERVER) == 0)
+ {
+ Strfnd fn(ma->from_inv);
+ 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 = m_env.getMap().getNodeMetadata(p);
+ if(meta && meta->typeId() == CONTENT_LOCKABLE_CHEST) {
+ LockingChestNodeMetadata *lcm = (LockingChestNodeMetadata*)meta;
+ if (lcm->getOwner() != player->getName())
+ return;
+ }
+ }
+ }
+ else if (ma->to_inv != "current_player" && (getPlayerPrivs(player) & PRIV_SERVER) == 0)
+ {
+ Strfnd fn(ma->to_inv);
+ 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 = m_env.getMap().getNodeMetadata(p);
+ if(meta && meta->typeId() == CONTENT_LOCKABLE_CHEST) {
+ LockingChestNodeMetadata *lcm = (LockingChestNodeMetadata*)meta;
+ if (lcm->getOwner() != player->getName())
+ return;
+ }
+ }
+ }
}
if(disable_action == false)