Extended block selecting
parent
e982d59385
commit
05a6ea0996
75
src/game.cpp
75
src/game.cpp
|
@ -301,7 +301,10 @@ void getPointedNode(Client *client, v3f player_position,
|
||||||
core::aabbox3d<f32> &nodehilightbox,
|
core::aabbox3d<f32> &nodehilightbox,
|
||||||
f32 d)
|
f32 d)
|
||||||
{
|
{
|
||||||
|
bool freeNodeFound = false;
|
||||||
|
|
||||||
f32 mindistance = BS * 1001;
|
f32 mindistance = BS * 1001;
|
||||||
|
f32 maxdistance = -BS * 1001;
|
||||||
|
|
||||||
v3s16 pos_i = floatToInt(player_position, BS);
|
v3s16 pos_i = floatToInt(player_position, BS);
|
||||||
|
|
||||||
|
@ -324,8 +327,8 @@ void getPointedNode(Client *client, v3f player_position,
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
n = client->getNode(v3s16(x,y,z));
|
n = client->getNode(v3s16(x,y,z));
|
||||||
if(content_pointable(n.getContent()) == false)
|
//if(content_pointable(n.getContent()) == false)
|
||||||
continue;
|
//continue;
|
||||||
}
|
}
|
||||||
catch(InvalidPositionException &e)
|
catch(InvalidPositionException &e)
|
||||||
{
|
{
|
||||||
|
@ -625,25 +628,69 @@ void getPointedNode(Client *client, v3f player_position,
|
||||||
|
|
||||||
if(facebox.intersectsWithLine(shootline))
|
if(facebox.intersectsWithLine(shootline))
|
||||||
{
|
{
|
||||||
nodefound = true;
|
if(content_pointable(n.getContent()) == true){
|
||||||
nodepos = np;
|
nodefound = true;
|
||||||
neighbourpos = np + dirs[i];
|
nodepos = np;
|
||||||
mindistance = distance;
|
neighbourpos = np + dirs[i];
|
||||||
|
mindistance = distance;
|
||||||
|
|
||||||
//nodehilightbox = facebox;
|
//nodehilightbox = facebox;
|
||||||
|
|
||||||
const float d = 0.502;
|
const float d = 0.502;
|
||||||
core::aabbox3d<f32> nodebox
|
core::aabbox3d<f32> nodebox
|
||||||
(-BS*d, -BS*d, -BS*d, BS*d, BS*d, BS*d);
|
(-BS*d, -BS*d, -BS*d, BS*d, BS*d, BS*d);
|
||||||
v3f nodepos_f = intToFloat(nodepos, BS);
|
v3f nodepos_f = intToFloat(nodepos, BS);
|
||||||
nodebox.MinEdge += nodepos_f;
|
nodebox.MinEdge += nodepos_f;
|
||||||
nodebox.MaxEdge += nodepos_f;
|
nodebox.MaxEdge += nodepos_f;
|
||||||
nodehilightbox = nodebox;
|
nodehilightbox = nodebox;
|
||||||
|
}else if(nodefound==false && np != pos_i && np != v3s16(pos_i.X,pos_i.Y+1,pos_i.Z) ){
|
||||||
|
//check if we can build here
|
||||||
|
//this can't be checked (not such material property)...
|
||||||
|
//but is it important here anyway?
|
||||||
|
|
||||||
|
bool can_build = false;
|
||||||
|
v3s16 ap;
|
||||||
|
static const v3s16 neigh_pos[] = { v3s16(0,0,1), v3s16(0,0,-1), v3s16(0,1,0), v3s16(0,-1,0), v3s16(1,0,0), v3s16(-1,0,0) };
|
||||||
|
for(int i=0; i<6; i++)
|
||||||
|
{
|
||||||
|
ap = np + neigh_pos[i];
|
||||||
|
try{
|
||||||
|
MapNode an = client->getNode(ap);
|
||||||
|
//check if we can `stick' to this node
|
||||||
|
if(!content_features(an).walkable) //FIXME: is this OK?
|
||||||
|
continue;
|
||||||
|
can_build = true;
|
||||||
|
goto after_check_neighbor;
|
||||||
|
}catch(InvalidPositionException&){}
|
||||||
|
}
|
||||||
|
after_check_neighbor:
|
||||||
|
if(can_build && distance > maxdistance){
|
||||||
|
|
||||||
|
maxdistance = distance;
|
||||||
|
|
||||||
|
//nodefound = true; //we can't do this here!
|
||||||
|
freeNodeFound = true; //instead, we set this and check at the end
|
||||||
|
nodepos = ap; //yes, these are swaped!
|
||||||
|
neighbourpos = np;
|
||||||
|
//mindistance = distance;
|
||||||
|
|
||||||
|
//nodehilightbox = facebox;
|
||||||
|
|
||||||
|
const float d = 0.502;
|
||||||
|
core::aabbox3d<f32> nodebox
|
||||||
|
(-BS*d, -BS*d, -BS*d, BS*d, BS*d, BS*d);
|
||||||
|
v3f nodepos_f = intToFloat(np, BS);
|
||||||
|
nodebox.MinEdge += nodepos_f;
|
||||||
|
nodebox.MaxEdge += nodepos_f;
|
||||||
|
nodehilightbox = nodebox;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // if distance < mindistance
|
} // if distance < mindistance
|
||||||
} // for dirs
|
} // for dirs
|
||||||
} // regular block
|
} // regular block
|
||||||
} // for coords
|
} // for coords
|
||||||
|
if(!nodefound && freeNodeFound) nodefound = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_skybox(video::IVideoDriver* driver,
|
void update_skybox(video::IVideoDriver* driver,
|
||||||
|
|
|
@ -2952,7 +2952,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||||
u16 newowner=0;
|
u16 newowner=0;
|
||||||
// Only allow borderstone if player already belongs to some clan
|
// Only allow borderstone if player already belongs to some clan
|
||||||
if(mitem->getMaterial() == CONTENT_BORDERSTONE)
|
if(mitem->getMaterial() == CONTENT_BORDERSTONE)
|
||||||
{ if(player->lastClan && player->clans.find(player->lastClan) == player->clans.end())
|
{ if(player->lastClan && !player->isClanMember(player->lastClan))
|
||||||
player->lastClan=0; // was invalid (no longer member?)
|
player->lastClan=0; // was invalid (no longer member?)
|
||||||
if(!player->lastClan)
|
if(!player->lastClan)
|
||||||
{ if(player->clanOwner)
|
{ if(player->clanOwner)
|
||||||
|
|
Loading…
Reference in New Issue