forked from oerkki/voxelands
borderstone part 2
This commit is contained in:
parent
101631d55f
commit
8ed9678852
|
@ -137,6 +137,8 @@
|
||||||
#default_privs = build, shout
|
#default_privs = build, shout
|
||||||
# enable a static spawnpoint (default unset)
|
# enable a static spawnpoint (default unset)
|
||||||
#static_spawnpoint = (0,0,0)
|
#static_spawnpoint = (0,0,0)
|
||||||
|
# the protection radius of borderstone
|
||||||
|
#borderstone_radius = 5
|
||||||
|
|
||||||
# Profiler data print interval. #0 = disable.
|
# Profiler data print interval. #0 = disable.
|
||||||
#profiler_print_interval = 0
|
#profiler_print_interval = 0
|
||||||
|
|
|
@ -107,7 +107,7 @@ struct CraftDef {
|
||||||
*/
|
*/
|
||||||
InventoryItem *craft_get_result(InventoryItem **items)
|
InventoryItem *craft_get_result(InventoryItem **items)
|
||||||
{
|
{
|
||||||
static CraftDef defs[32];
|
static CraftDef defs[33];
|
||||||
static int defs_init = 0;
|
static int defs_init = 0;
|
||||||
|
|
||||||
// only initialise (and hence allocate) these once
|
// only initialise (and hence allocate) these once
|
||||||
|
|
|
@ -345,9 +345,11 @@ void content_mapnode_init()
|
||||||
i = CONTENT_BORDERSTONE;
|
i = CONTENT_BORDERSTONE;
|
||||||
f = &content_features(i);
|
f = &content_features(i);
|
||||||
f->setAllTextures("borderstone.png");
|
f->setAllTextures("borderstone.png");
|
||||||
f->setInventoryTextureCube("morderstone.png", "borderstone.png", "borderstone.png");
|
f->setInventoryTextureCube("borderstone.png", "borderstone.png", "borderstone.png");
|
||||||
f->is_ground_content = true;
|
f->is_ground_content = true;
|
||||||
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||||
|
if(f->initial_metadata == NULL)
|
||||||
|
f->initial_metadata = new BorderStoneNodeMetadata();
|
||||||
setStoneLikeDiggingProperties(f->digging_properties, 2.0);
|
setStoneLikeDiggingProperties(f->digging_properties, 2.0);
|
||||||
|
|
||||||
i = CONTENT_WOOD;
|
i = CONTENT_WOOD;
|
||||||
|
|
|
@ -182,6 +182,44 @@ std::string LockingChestNodeMetadata::getInventoryDrawSpecString()
|
||||||
"list[current_player;main;0,5;8,4;]";
|
"list[current_player;main;0,5;8,4;]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
BorderStoneNodeMetadata
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Prototype
|
||||||
|
BorderStoneNodeMetadata proto_BorderStoneNodeMetadata;
|
||||||
|
|
||||||
|
BorderStoneNodeMetadata::BorderStoneNodeMetadata()
|
||||||
|
{
|
||||||
|
NodeMetadata::registerType(typeId(), create);
|
||||||
|
}
|
||||||
|
BorderStoneNodeMetadata::~BorderStoneNodeMetadata()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
u16 BorderStoneNodeMetadata::typeId() const
|
||||||
|
{
|
||||||
|
return CONTENT_BORDERSTONE;
|
||||||
|
}
|
||||||
|
NodeMetadata* BorderStoneNodeMetadata::create(std::istream &is)
|
||||||
|
{
|
||||||
|
BorderStoneNodeMetadata *d = new BorderStoneNodeMetadata();
|
||||||
|
d->setOwner(deSerializeString(is));
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
NodeMetadata* BorderStoneNodeMetadata::clone()
|
||||||
|
{
|
||||||
|
BorderStoneNodeMetadata *d = new BorderStoneNodeMetadata();
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
void BorderStoneNodeMetadata::serializeBody(std::ostream &os)
|
||||||
|
{
|
||||||
|
os<<serializeString(m_text);
|
||||||
|
}
|
||||||
|
std::string BorderStoneNodeMetadata::infoText()
|
||||||
|
{
|
||||||
|
return std::string("Border Stone owned by '")+m_text+"'";
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
FurnaceNodeMetadata
|
FurnaceNodeMetadata
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -85,6 +85,25 @@ private:
|
||||||
std::string m_text;
|
std::string m_text;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class BorderStoneNodeMetadata : public NodeMetadata
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BorderStoneNodeMetadata();
|
||||||
|
~BorderStoneNodeMetadata();
|
||||||
|
|
||||||
|
virtual u16 typeId() const;
|
||||||
|
static NodeMetadata* create(std::istream &is);
|
||||||
|
virtual NodeMetadata* clone();
|
||||||
|
virtual void serializeBody(std::ostream &os);
|
||||||
|
virtual std::string infoText();
|
||||||
|
|
||||||
|
virtual std::string getOwner(){ return m_text; }
|
||||||
|
virtual void setOwner(std::string t){ m_text = t; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string m_text;
|
||||||
|
};
|
||||||
|
|
||||||
class FurnaceNodeMetadata : public NodeMetadata
|
class FurnaceNodeMetadata : public NodeMetadata
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -93,6 +93,7 @@ void set_default_settings(Settings *settings)
|
||||||
settings->setDefault("give_initial_stuff", "false");
|
settings->setDefault("give_initial_stuff", "false");
|
||||||
settings->setDefault("default_password", "");
|
settings->setDefault("default_password", "");
|
||||||
settings->setDefault("default_privs", "build, shout");
|
settings->setDefault("default_privs", "build, shout");
|
||||||
|
settings->setDefault("borderstone_radius","5");
|
||||||
|
|
||||||
settings->setDefault("profiler_print_interval", "0");
|
settings->setDefault("profiler_print_interval", "0");
|
||||||
settings->setDefault("enable_mapgen_debug_info", "false");
|
settings->setDefault("enable_mapgen_debug_info", "false");
|
||||||
|
|
|
@ -2477,6 +2477,25 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||||
<<" because privileges are "<<getPlayerPrivs(player)
|
<<" because privileges are "<<getPlayerPrivs(player)
|
||||||
<<std::endl;
|
<<std::endl;
|
||||||
cannot_remove_node = true;
|
cannot_remove_node = true;
|
||||||
|
}else{
|
||||||
|
s16 max_d = g_settings->getS16("borderstone_radius");
|
||||||
|
v3s16 test_p;
|
||||||
|
MapNode testnode;
|
||||||
|
for(s16 z=-max_d; !cannot_remove_node && z<=max_d; z++) {
|
||||||
|
for(s16 y=-max_d; !cannot_remove_node && y<=max_d; y++) {
|
||||||
|
for(s16 x=-max_d; !cannot_remove_node && x<=max_d; x++) {
|
||||||
|
test_p = p_under + v3s16(x,y,z);
|
||||||
|
NodeMetadata *meta = m_env.getMap().getNodeMetadata(test_p);
|
||||||
|
if (meta && meta->typeId() == CONTENT_BORDERSTONE) {
|
||||||
|
BorderStoneNodeMetadata *bsm = (BorderStoneNodeMetadata*)meta;
|
||||||
|
if (bsm->getOwner() != player->getName()) {
|
||||||
|
cannot_remove_node = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2727,6 +2746,23 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||||
if(item == NULL)
|
if(item == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
s16 max_d = g_settings->getS16("borderstone_radius");
|
||||||
|
v3s16 test_p;
|
||||||
|
MapNode testnode;
|
||||||
|
for(s16 z=-max_d; z<=max_d; z++) {
|
||||||
|
for(s16 y=-max_d; y<=max_d; y++) {
|
||||||
|
for(s16 x=-max_d; x<=max_d; x++) {
|
||||||
|
test_p = p_over + v3s16(x,y,z);
|
||||||
|
NodeMetadata *meta = m_env.getMap().getNodeMetadata(test_p);
|
||||||
|
if (meta && meta->typeId() == CONTENT_BORDERSTONE) {
|
||||||
|
BorderStoneNodeMetadata *bsm = (BorderStoneNodeMetadata*)meta;
|
||||||
|
if (bsm->getOwner() != player->getName())
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Handle material items
|
Handle material items
|
||||||
*/
|
*/
|
||||||
|
@ -2775,6 +2811,26 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||||
MapNode n;
|
MapNode n;
|
||||||
n.setContent(mitem->getMaterial());
|
n.setContent(mitem->getMaterial());
|
||||||
|
|
||||||
|
// don't allow borderstone to be place near another player's borderstone
|
||||||
|
if (n.getContent() == CONTENT_BORDERSTONE) {
|
||||||
|
s16 max_d = g_settings->getS16("borderstone_radius")*2;
|
||||||
|
v3s16 test_p;
|
||||||
|
MapNode testnode;
|
||||||
|
for(s16 z=-max_d; z<=max_d; z++) {
|
||||||
|
for(s16 y=-max_d; y<=max_d; y++) {
|
||||||
|
for(s16 x=-max_d; x<=max_d; x++) {
|
||||||
|
test_p = p_over + v3s16(x,y,z);
|
||||||
|
NodeMetadata *meta = m_env.getMap().getNodeMetadata(test_p);
|
||||||
|
if (meta && meta->typeId() == CONTENT_BORDERSTONE) {
|
||||||
|
BorderStoneNodeMetadata *bsm = (BorderStoneNodeMetadata*)meta;
|
||||||
|
if (bsm->getOwner() != player->getName())
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
actionstream<<player->getName()<<" places material "
|
actionstream<<player->getName()<<" places material "
|
||||||
<<(int)mitem->getMaterial()
|
<<(int)mitem->getMaterial()
|
||||||
<<" at "<<PP(p_under)<<std::endl;
|
<<" at "<<PP(p_under)<<std::endl;
|
||||||
|
|
Loading…
Reference in New Issue