aboutsummaryrefslogtreecommitdiff
path: root/src/server.cpp
diff options
context:
space:
mode:
authorKahrl <kahrl@gmx.net>2011-11-27 05:01:38 +0200
committerPerttu Ahola <celeron55@gmail.com>2011-11-29 19:13:54 +0200
commitf42c57d9a885450014cadd56a0eaf7c79eefebf4 (patch)
tree2ad93e18ac16b4b8c362a58ce046cb18be4d3e00 /src/server.cpp
parent82a460ec90b4537926f31603219504bce8817ac2 (diff)
downloadminetest-f42c57d9a885450014cadd56a0eaf7c79eefebf4.tar.gz
minetest-f42c57d9a885450014cadd56a0eaf7c79eefebf4.tar.bz2
minetest-f42c57d9a885450014cadd56a0eaf7c79eefebf4.zip
Add IDropAction and related stuff
Diffstat (limited to 'src/server.cpp')
-rw-r--r--src/server.cpp44
1 files changed, 37 insertions, 7 deletions
diff --git a/src/server.cpp b/src/server.cpp
index 7581f7a2b..66cc099e3 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -3032,7 +3032,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
/*
Create the object
*/
- ServerActiveObject *obj = item->createSAO(m_env, 0, pos);
+ ServerActiveObject *obj = item->createSAO(m_env, pos);
if(obj == NULL)
{
@@ -3243,7 +3243,7 @@ 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;
+ disable_action = true;
}
// 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)
@@ -3260,7 +3260,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
if(meta && meta->typeId() == LEGN(m_nodedef, "CONTENT_LOCKABLE_CHEST")) {
LockingChestNodeMetadata *lcm = (LockingChestNodeMetadata*)meta;
if (lcm->getOwner() != player->getName())
- return;
+ disable_action = true;
}
}
}
@@ -3278,7 +3278,36 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
if(meta && meta->typeId() == LEGN(m_nodedef, "CONTENT_LOCKABLE_CHEST")) {
LockingChestNodeMetadata *lcm = (LockingChestNodeMetadata*)meta;
if (lcm->getOwner() != player->getName())
- return;
+ disable_action = true;
+ }
+ }
+ }
+ }
+
+ if(a->getType() == IACTION_DROP)
+ {
+ IDropAction *da = (IDropAction*)a;
+ // Disallow dropping items if not allowed to build
+ if((getPlayerPrivs(player) & PRIV_BUILD) == 0)
+ {
+ disable_action = true;
+ }
+ // if it's a locking chest, only allow the owner or server admins to drop items
+ else if (da->from_inv != "current_player" && (getPlayerPrivs(player) & PRIV_SERVER) == 0)
+ {
+ Strfnd fn(da->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() == LEGN(m_nodedef, "CONTENT_LOCKABLE_CHEST")) {
+ LockingChestNodeMetadata *lcm = (LockingChestNodeMetadata*)meta;
+ if (lcm->getOwner() != player->getName())
+ disable_action = true;
}
}
}
@@ -3287,9 +3316,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
if(disable_action == false)
{
// Feed action to player inventory
- a->apply(&c, this);
- // Eat the action
- delete a;
+ a->apply(&c, this, m_env);
}
else
{
@@ -3297,6 +3324,9 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
UpdateCrafting(player->peer_id);
SendInventory(player->peer_id);
}
+
+ // Eat the action
+ delete a;
}
else
{