1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-11 17:51:04 +00:00

added dedicated server build without irrlicht

This commit is contained in:
Perttu Ahola 2010-12-19 19:11:05 +02:00
parent 0ca9423b8b
commit ab7477c4c3
19 changed files with 669 additions and 125 deletions

View file

@ -34,7 +34,6 @@ MapBlock::MapBlock(NodeContainer *parent, v3s16 pos, bool dummy):
m_pos(pos),
changed(true),
is_underground(false),
m_mesh_expired(false),
m_day_night_differs(false),
m_objects(this)
{
@ -42,17 +41,16 @@ MapBlock::MapBlock(NodeContainer *parent, v3s16 pos, bool dummy):
if(dummy == false)
reallocate();
#ifndef SERVER
m_mesh_expired = false;
mesh_mutex.Init();
mesh = NULL;
/*for(s32 i=0; i<DAYNIGHT_CACHE_COUNT; i++)
{
mesh[i] = NULL;
}*/
#endif
}
MapBlock::~MapBlock()
{
#ifndef SERVER
{
JMutexAutoLock lock(mesh_mutex);
@ -61,15 +59,8 @@ MapBlock::~MapBlock()
mesh->drop();
mesh = NULL;
}
/*for(s32 i=0; i<DAYNIGHT_CACHE_COUNT; i++)
{
if(mesh[i] != NULL)
{
mesh[i]->drop();
mesh[i] = NULL;
}
}*/
}
#endif
if(data)
delete[] data;
@ -136,6 +127,52 @@ MapNode MapBlock::getNodeParentNoEx(v3s16 p)
}
}
/*
Parameters must consist of air and !air.
Order doesn't matter.
If either of the nodes doesn't exist, light is 0.
parameters:
daynight_ratio: 0...1000
n: getNodeParent(p)
n2: getNodeParent(p + face_dir)
face_dir: axis oriented unit vector from p to p2
*/
u8 MapBlock::getFaceLight(u32 daynight_ratio, MapNode n, MapNode n2,
v3s16 face_dir)
{
try{
u8 light;
u8 l1 = n.getLightBlend(daynight_ratio);
u8 l2 = n2.getLightBlend(daynight_ratio);
if(l1 > l2)
light = l1;
else
light = l2;
// Make some nice difference to different sides
/*if(face_dir.X == 1 || face_dir.Z == 1 || face_dir.Y == -1)
light = diminish_light(diminish_light(light));
else if(face_dir.X == -1 || face_dir.Z == -1)
light = diminish_light(light);*/
if(face_dir.X == 1 || face_dir.X == -1 || face_dir.Y == -1)
light = diminish_light(diminish_light(light));
else if(face_dir.Z == 1 || face_dir.Z == -1)
light = diminish_light(light);
return light;
}
catch(InvalidPositionException &e)
{
return 0;
}
}
#ifndef SERVER
void MapBlock::makeFastFace(TileSpec tile, u8 light, v3f p,
v3s16 dir, v3f scale, v3f posRelative_f,
core::array<FastFace> &dest)
@ -229,50 +266,6 @@ void MapBlock::makeFastFace(TileSpec tile, u8 light, v3f p,
//return f;
}
/*
Parameters must consist of air and !air.
Order doesn't matter.
If either of the nodes doesn't exist, light is 0.
parameters:
daynight_ratio: 0...1000
n: getNodeParent(p)
n2: getNodeParent(p + face_dir)
face_dir: axis oriented unit vector from p to p2
*/
u8 MapBlock::getFaceLight(u32 daynight_ratio, MapNode n, MapNode n2,
v3s16 face_dir)
{
try{
u8 light;
u8 l1 = n.getLightBlend(daynight_ratio);
u8 l2 = n2.getLightBlend(daynight_ratio);
if(l1 > l2)
light = l1;
else
light = l2;
// Make some nice difference to different sides
/*if(face_dir.X == 1 || face_dir.Z == 1 || face_dir.Y == -1)
light = diminish_light(diminish_light(light));
else if(face_dir.X == -1 || face_dir.Z == -1)
light = diminish_light(light);*/
if(face_dir.X == 1 || face_dir.X == -1 || face_dir.Y == -1)
light = diminish_light(diminish_light(light));
else if(face_dir.Z == 1 || face_dir.Z == -1)
light = diminish_light(light);
return light;
}
catch(InvalidPositionException &e)
{
return 0;
}
}
/*
Gets node tile from any place relative to block.
Returns TILE_NODE if doesn't exist or should not be drawn.
@ -844,6 +837,8 @@ void MapBlock::updateMesh(u32 daynight_ratio)
}
}*/
#endif // !SERVER
/*
Propagates sunlight down through the block.
Doesn't modify nodes that are not affected by sunlight.