Merged CiaranG's fence and fixed two things
commit
12ca835e14
132
src/mapblock.cpp
132
src/mapblock.cpp
|
@ -729,6 +729,72 @@ private:
|
||||||
core::array<PreMeshBuffer> m_prebuffers;
|
core::array<PreMeshBuffer> m_prebuffers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void makeCuboid(video::SMaterial &material, MeshCollector *collector,
|
||||||
|
AtlasPointer* pa, video::SColor &c,
|
||||||
|
v3f &pos, f32 rx, f32 ry, f32 rz)
|
||||||
|
{
|
||||||
|
video::S3DVertex v[4] =
|
||||||
|
{
|
||||||
|
video::S3DVertex(0,0,0, 0,0,0, c,
|
||||||
|
pa->x0(), pa->y1()),
|
||||||
|
video::S3DVertex(0,0,0, 0,0,0, c,
|
||||||
|
pa->x1(), pa->y1()),
|
||||||
|
video::S3DVertex(0,0,0, 0,0,0, c,
|
||||||
|
pa->x1(), pa->y0()),
|
||||||
|
video::S3DVertex(0,0,0, 0,0,0, c,
|
||||||
|
pa->x0(), pa->y0())
|
||||||
|
};
|
||||||
|
|
||||||
|
for(int i=0;i<6;i++)
|
||||||
|
{
|
||||||
|
switch(i)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
v[0].Pos.X=-rx; v[0].Pos.Y= ry; v[0].Pos.Z=-rz;
|
||||||
|
v[1].Pos.X=-rx; v[1].Pos.Y= ry; v[1].Pos.Z= rz;
|
||||||
|
v[2].Pos.X= rx; v[2].Pos.Y= ry; v[2].Pos.Z= rz;
|
||||||
|
v[3].Pos.X= rx; v[3].Pos.Y= ry, v[3].Pos.Z=-rz;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
v[0].Pos.X=-rx; v[0].Pos.Y= ry; v[0].Pos.Z=-rz;
|
||||||
|
v[1].Pos.X= rx; v[1].Pos.Y= ry; v[1].Pos.Z=-rz;
|
||||||
|
v[2].Pos.X= rx; v[2].Pos.Y=-ry; v[2].Pos.Z=-rz;
|
||||||
|
v[3].Pos.X=-rx; v[3].Pos.Y=-ry, v[3].Pos.Z=-rz;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
v[0].Pos.X= rx; v[0].Pos.Y= ry; v[0].Pos.Z=-rz;
|
||||||
|
v[1].Pos.X= rx; v[1].Pos.Y= ry; v[1].Pos.Z= rz;
|
||||||
|
v[2].Pos.X= rx; v[2].Pos.Y=-ry; v[2].Pos.Z= rz;
|
||||||
|
v[3].Pos.X= rx; v[3].Pos.Y=-ry, v[3].Pos.Z=-rz;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
v[0].Pos.X= rx; v[0].Pos.Y= ry; v[0].Pos.Z= rz;
|
||||||
|
v[1].Pos.X=-rx; v[1].Pos.Y= ry; v[1].Pos.Z= rz;
|
||||||
|
v[2].Pos.X=-rx; v[2].Pos.Y=-ry; v[2].Pos.Z= rz;
|
||||||
|
v[3].Pos.X= rx; v[3].Pos.Y=-ry, v[3].Pos.Z= rz;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
v[0].Pos.X=-rx; v[0].Pos.Y= ry; v[0].Pos.Z= rz;
|
||||||
|
v[1].Pos.X=-rx; v[1].Pos.Y= ry; v[1].Pos.Z=-rz;
|
||||||
|
v[2].Pos.X=-rx; v[2].Pos.Y=-ry; v[2].Pos.Z=-rz;
|
||||||
|
v[3].Pos.X=-rx; v[3].Pos.Y=-ry, v[3].Pos.Z= rz;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
v[0].Pos.X= rx; v[0].Pos.Y=-ry; v[0].Pos.Z= rz;
|
||||||
|
v[1].Pos.X=-rx; v[1].Pos.Y=-ry; v[1].Pos.Z= rz;
|
||||||
|
v[2].Pos.X=-rx; v[2].Pos.Y=-ry; v[2].Pos.Z=-rz;
|
||||||
|
v[3].Pos.X= rx; v[3].Pos.Y=-ry, v[3].Pos.Z=-rz;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for(u16 i=0; i<4; i++)
|
||||||
|
v[i].Pos += pos;
|
||||||
|
u16 indices[] = {0,1,2,2,3,0};
|
||||||
|
collector->append(material, v, 4, indices, 6);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
scene::SMesh* makeMapBlockMesh(MeshMakeData *data)
|
scene::SMesh* makeMapBlockMesh(MeshMakeData *data)
|
||||||
{
|
{
|
||||||
// 4-21ms for MAP_BLOCKSIZE=16
|
// 4-21ms for MAP_BLOCKSIZE=16
|
||||||
|
@ -911,6 +977,15 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data)
|
||||||
g_texturesource->getTextureId("glass.png"));
|
g_texturesource->getTextureId("glass.png"));
|
||||||
material_glass.setTexture(0, pa_glass.atlas);
|
material_glass.setTexture(0, pa_glass.atlas);
|
||||||
|
|
||||||
|
// Wood material
|
||||||
|
video::SMaterial material_wood;
|
||||||
|
material_wood.setFlag(video::EMF_LIGHTING, false);
|
||||||
|
material_wood.setFlag(video::EMF_BILINEAR_FILTER, false);
|
||||||
|
material_wood.setFlag(video::EMF_FOG_ENABLE, true);
|
||||||
|
material_wood.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
|
||||||
|
AtlasPointer pa_wood = g_texturesource->getTexture(
|
||||||
|
g_texturesource->getTextureId("wood.png"));
|
||||||
|
material_wood.setTexture(0, pa_wood.atlas);
|
||||||
|
|
||||||
for(s16 z=0; z<MAP_BLOCKSIZE; z++)
|
for(s16 z=0; z<MAP_BLOCKSIZE; z++)
|
||||||
for(s16 y=0; y<MAP_BLOCKSIZE; y++)
|
for(s16 y=0; y<MAP_BLOCKSIZE; y++)
|
||||||
|
@ -1480,6 +1555,63 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data)
|
||||||
collector.append(material_glass, vertices, 4, indices, 6);
|
collector.append(material_glass, vertices, 4, indices, 6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
Add fence
|
||||||
|
*/
|
||||||
|
else if(n.d == CONTENT_FENCE)
|
||||||
|
{
|
||||||
|
u8 l = decode_light(undiminish_light(n.getLightBlend(data->m_daynight_ratio)));
|
||||||
|
video::SColor c(255,l,l,l);
|
||||||
|
|
||||||
|
const f32 post_rad=(f32)BS/10;
|
||||||
|
const f32 bar_rad=(f32)BS/20;
|
||||||
|
const f32 bar_len=(f32)(BS/2)-post_rad;
|
||||||
|
|
||||||
|
// The post - always present
|
||||||
|
v3f pos = intToFloat(p+blockpos_nodes, BS);
|
||||||
|
makeCuboid(material_wood, &collector,
|
||||||
|
&pa_wood, c, pos,
|
||||||
|
post_rad,BS/2,post_rad);
|
||||||
|
|
||||||
|
// Now a section of fence, +X, if there's a post there
|
||||||
|
v3s16 p2 = p;
|
||||||
|
p2.X++;
|
||||||
|
MapNode n2 = data->m_vmanip.getNodeNoEx(blockpos_nodes + p2);
|
||||||
|
if(n2.d == CONTENT_FENCE)
|
||||||
|
{
|
||||||
|
pos = intToFloat(p+blockpos_nodes, BS);
|
||||||
|
pos.X += BS/2;
|
||||||
|
pos.Y += BS/4;
|
||||||
|
makeCuboid(material_wood, &collector,
|
||||||
|
&pa_wood, c, pos,
|
||||||
|
bar_len,bar_rad,bar_rad);
|
||||||
|
|
||||||
|
pos.Y -= BS/2;
|
||||||
|
makeCuboid(material_wood, &collector,
|
||||||
|
&pa_wood, c, pos,
|
||||||
|
bar_len,bar_rad,bar_rad);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now a section of fence, +Z, if there's a post there
|
||||||
|
p2 = p;
|
||||||
|
p2.Z++;
|
||||||
|
n2 = data->m_vmanip.getNodeNoEx(blockpos_nodes + p2);
|
||||||
|
if(n2.d == CONTENT_FENCE)
|
||||||
|
{
|
||||||
|
pos = intToFloat(p+blockpos_nodes, BS);
|
||||||
|
pos.Z += BS/2;
|
||||||
|
pos.Y += BS/4;
|
||||||
|
makeCuboid(material_wood, &collector,
|
||||||
|
&pa_wood, c, pos,
|
||||||
|
bar_rad,bar_rad,bar_len);
|
||||||
|
pos.Y -= BS/2;
|
||||||
|
makeCuboid(material_wood, &collector,
|
||||||
|
&pa_wood, c, pos,
|
||||||
|
bar_rad,bar_rad,bar_len);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -216,6 +216,14 @@ void init_mapnode()
|
||||||
f->solidness = 0; // drawn separately, makes no faces
|
f->solidness = 0; // drawn separately, makes no faces
|
||||||
f->setInventoryTextureCube("glass.png", "glass.png", "glass.png");
|
f->setInventoryTextureCube("glass.png", "glass.png", "glass.png");
|
||||||
|
|
||||||
|
i = CONTENT_FENCE;
|
||||||
|
f = &g_content_features[i];
|
||||||
|
f->light_propagates = true;
|
||||||
|
f->param_type = CPT_LIGHT;
|
||||||
|
f->is_ground_content = true;
|
||||||
|
f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
|
||||||
|
f->solidness = 0; // drawn separately, makes no faces
|
||||||
|
f->air_equivalent = true; // grass grows underneath
|
||||||
|
|
||||||
// Deprecated
|
// Deprecated
|
||||||
i = CONTENT_COALSTONE;
|
i = CONTENT_COALSTONE;
|
||||||
|
|
|
@ -100,6 +100,7 @@ void init_content_inventory_texture_paths();
|
||||||
#define CONTENT_COBBLE 18
|
#define CONTENT_COBBLE 18
|
||||||
#define CONTENT_STEEL 19
|
#define CONTENT_STEEL 19
|
||||||
#define CONTENT_GLASS 20
|
#define CONTENT_GLASS 20
|
||||||
|
#define CONTENT_FENCE 21
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Content feature list
|
Content feature list
|
||||||
|
|
|
@ -73,6 +73,7 @@ void initializeMaterialProperties()
|
||||||
setWoodLikeDiggingProperties(CONTENT_TREE, 1.0);
|
setWoodLikeDiggingProperties(CONTENT_TREE, 1.0);
|
||||||
setWoodLikeDiggingProperties(CONTENT_LEAVES, 0.15);
|
setWoodLikeDiggingProperties(CONTENT_LEAVES, 0.15);
|
||||||
setWoodLikeDiggingProperties(CONTENT_GLASS, 0.15);
|
setWoodLikeDiggingProperties(CONTENT_GLASS, 0.15);
|
||||||
|
setWoodLikeDiggingProperties(CONTENT_FENCE, 0.75);
|
||||||
setWoodLikeDiggingProperties(CONTENT_WOOD, 0.75);
|
setWoodLikeDiggingProperties(CONTENT_WOOD, 0.75);
|
||||||
setWoodLikeDiggingProperties(CONTENT_CHEST, 1.0);
|
setWoodLikeDiggingProperties(CONTENT_CHEST, 1.0);
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,8 @@ std::wstring privsToString(u64 privs)
|
||||||
os<<L"settime,";
|
os<<L"settime,";
|
||||||
if(privs & PRIV_PRIVS)
|
if(privs & PRIV_PRIVS)
|
||||||
os<<L"privs,";
|
os<<L"privs,";
|
||||||
|
if(privs & PRIV_SHOUT)
|
||||||
|
os<<L"shout,";
|
||||||
if(os.tellp())
|
if(os.tellp())
|
||||||
{
|
{
|
||||||
// Drop the trailing comma. (Why on earth can't
|
// Drop the trailing comma. (Why on earth can't
|
||||||
|
@ -65,6 +67,8 @@ u64 stringToPrivs(std::wstring str)
|
||||||
privs |= PRIV_SETTIME;
|
privs |= PRIV_SETTIME;
|
||||||
else if(*i == L"privs")
|
else if(*i == L"privs")
|
||||||
privs |= PRIV_PRIVS;
|
privs |= PRIV_PRIVS;
|
||||||
|
else if(*i == L"shout")
|
||||||
|
privs |= PRIV_SHOUT;
|
||||||
else
|
else
|
||||||
return PRIV_INVALID;
|
return PRIV_INVALID;
|
||||||
}
|
}
|
||||||
|
|
19
src/player.h
19
src/player.h
|
@ -34,14 +34,19 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
// of the player, and define things they're allowed to do. See also
|
// of the player, and define things they're allowed to do. See also
|
||||||
// the static methods Player::privsToString and stringToPrivs that
|
// the static methods Player::privsToString and stringToPrivs that
|
||||||
// convert these to human-readable form.
|
// convert these to human-readable form.
|
||||||
const u64 PRIV_BUILD = 1; // Can build - i.e. modify the world
|
const u64 PRIV_BUILD = 1; // Can build - i.e. modify the world
|
||||||
// (not enforced yet)
|
const u64 PRIV_TELEPORT = 2; // Can teleport
|
||||||
const u64 PRIV_TELEPORT = 2; // Can teleport
|
const u64 PRIV_SETTIME = 4; // Can set the time
|
||||||
const u64 PRIV_SETTIME = 4; // Can set the time
|
const u64 PRIV_PRIVS = 8; // Can grant and revoke privileges
|
||||||
const u64 PRIV_PRIVS = 8; // Can grant and revoke privileges
|
const u64 PRIV_SERVER = 16; // Can manage the server (e.g. shutodwn
|
||||||
const u64 PRIV_SERVER = 16; // Can manage the server (e.g. shutodwn ,settings)
|
// ,settings)
|
||||||
|
const u64 PRIV_SHOUT = 32; // Can broadcast chat messages to all
|
||||||
|
// players
|
||||||
|
|
||||||
const u64 PRIV_DEFAULT = PRIV_BUILD;
|
// Default privileges - these can be overriden for new players using the
|
||||||
|
// config option "default_privs" - however, this value still applies for
|
||||||
|
// players that existed before the privileges system was added.
|
||||||
|
const u64 PRIV_DEFAULT = PRIV_BUILD|PRIV_SHOUT;
|
||||||
const u64 PRIV_ALL = 0x7FFFFFFFFFFFFFFFULL;
|
const u64 PRIV_ALL = 0x7FFFFFFFFFFFFFFFULL;
|
||||||
const u64 PRIV_INVALID = 0x8000000000000000ULL;
|
const u64 PRIV_INVALID = 0x8000000000000000ULL;
|
||||||
|
|
||||||
|
|
|
@ -2908,6 +2908,12 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||||
// Whether to send to other players
|
// Whether to send to other players
|
||||||
bool send_to_others = false;
|
bool send_to_others = false;
|
||||||
|
|
||||||
|
// Local player gets all privileges regardless of
|
||||||
|
// what's set on their account.
|
||||||
|
u64 privs = player->privs;
|
||||||
|
if(g_settings.get("name") == player->getName())
|
||||||
|
privs = PRIV_ALL;
|
||||||
|
|
||||||
// Parse commands
|
// Parse commands
|
||||||
std::wstring commandprefix = L"/#";
|
std::wstring commandprefix = L"/#";
|
||||||
if(message.substr(0, commandprefix.size()) == commandprefix)
|
if(message.substr(0, commandprefix.size()) == commandprefix)
|
||||||
|
@ -2916,12 +2922,6 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||||
|
|
||||||
message = message.substr(commandprefix.size());
|
message = message.substr(commandprefix.size());
|
||||||
|
|
||||||
// Local player gets all privileges regardless of
|
|
||||||
// what's set on their account.
|
|
||||||
u64 privs = player->privs;
|
|
||||||
if(g_settings.get("name") == player->getName())
|
|
||||||
privs = PRIV_ALL;
|
|
||||||
|
|
||||||
ServerCommandContext *ctx = new ServerCommandContext(
|
ServerCommandContext *ctx = new ServerCommandContext(
|
||||||
str_split(message, L' '),
|
str_split(message, L' '),
|
||||||
this,
|
this,
|
||||||
|
@ -2937,13 +2937,19 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
line += L"<";
|
if(privs & PRIV_SHOUT)
|
||||||
/*if(is_operator)
|
{
|
||||||
line += L"@";*/
|
line += L"<";
|
||||||
line += name;
|
line += name;
|
||||||
line += L"> ";
|
line += L"> ";
|
||||||
line += message;
|
line += message;
|
||||||
send_to_others = true;
|
send_to_others = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
line += L"Server: You are not allowed to shout";
|
||||||
|
send_to_sender = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(line != L"")
|
if(line != L"")
|
||||||
|
@ -3664,6 +3670,23 @@ void Server::UpdateCrafting(u16 peer_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fence
|
||||||
|
if(!found)
|
||||||
|
{
|
||||||
|
ItemSpec specs[9];
|
||||||
|
specs[3] = ItemSpec(ITEM_CRAFT, "Stick");
|
||||||
|
specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
|
||||||
|
specs[5] = ItemSpec(ITEM_CRAFT, "Stick");
|
||||||
|
specs[6] = ItemSpec(ITEM_CRAFT, "Stick");
|
||||||
|
specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
|
||||||
|
specs[8] = ItemSpec(ITEM_CRAFT, "Stick");
|
||||||
|
if(checkItemCombination(items, specs))
|
||||||
|
{
|
||||||
|
rlist->addItem(new MaterialItem(CONTENT_FENCE, 2));
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Sign
|
// Sign
|
||||||
if(!found)
|
if(!found)
|
||||||
{
|
{
|
||||||
|
@ -4040,6 +4063,7 @@ void setCreativeInventory(Player *player)
|
||||||
CONTENT_TREE,
|
CONTENT_TREE,
|
||||||
CONTENT_LEAVES,
|
CONTENT_LEAVES,
|
||||||
CONTENT_GLASS,
|
CONTENT_GLASS,
|
||||||
|
CONTENT_FENCE,
|
||||||
CONTENT_MESE,
|
CONTENT_MESE,
|
||||||
CONTENT_WATERSOURCE,
|
CONTENT_WATERSOURCE,
|
||||||
CONTENT_CLOUD,
|
CONTENT_CLOUD,
|
||||||
|
@ -4185,6 +4209,9 @@ Player *Server::emergePlayer(const char *name, const char *password, u16 peer_id
|
||||||
player->updateName(name);
|
player->updateName(name);
|
||||||
player->updatePassword(password);
|
player->updatePassword(password);
|
||||||
|
|
||||||
|
if(g_settings.exists("default_privs"))
|
||||||
|
player->privs = g_settings.getU64("default_privs");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Set player position
|
Set player position
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue