1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

added locking chests - clean patch

This commit is contained in:
darkrose 2011-09-22 19:11:48 +10:00
parent ae6d83a41e
commit 582e450bad
10 changed files with 186 additions and 5 deletions

View file

@ -28,6 +28,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "porting.h"
#include "mapgen.h"
#include "nodemetadata.h"
#include "content_nodemeta.h"
#include "content_mapnode.h"
/*
SQLite format specification:
@ -890,7 +892,7 @@ void Map::updateLighting(core::map<v3s16, MapBlock*> & a_blocks,
/*
*/
void Map::addNodeAndUpdate(v3s16 p, MapNode n,
core::map<v3s16, MapBlock*> &modified_blocks)
core::map<v3s16, MapBlock*> &modified_blocks, std::string &player_name)
{
/*PrintInfo(m_dout);
m_dout<<DTIME<<"Map::addNodeAndUpdate(): p=("
@ -1014,8 +1016,20 @@ void Map::addNodeAndUpdate(v3s16 p, MapNode n,
if(meta_proto)
{
NodeMetadata *meta = meta_proto->clone();
/* lockable chest, insert the owner's name */
if (meta->typeId() == CONTENT_LOCKABLE_CHEST)
{
LockingChestNodeMetadata *lcm = (LockingChestNodeMetadata*)meta;
lcm->setOwner(player_name);
}
setNodeMetadata(p, meta);
}
else if (n.getContent() == CONTENT_LOCKABLE_CHEST)
{
LockingChestNodeMetadata *lcm = new LockingChestNodeMetadata();
lcm->setOwner(player_name);
setNodeMetadata(p, (NodeMetadata*)lcm);
}
/*
If node is under sunlight and doesn't let sunlight through,
@ -1290,7 +1304,8 @@ bool Map::addNodeWithEvent(v3s16 p, MapNode n)
bool succeeded = true;
try{
core::map<v3s16, MapBlock*> modified_blocks;
addNodeAndUpdate(p, n, modified_blocks);
std::string st = std::string("");
addNodeAndUpdate(p, n, modified_blocks, st);
// Copy modified_blocks to event
for(core::map<v3s16, MapBlock*>::Iterator