From ab7477c4c3e2a3647dc4fb65c71567946d33b0e3 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sun, 19 Dec 2010 19:11:05 +0200 Subject: added dedicated server build without irrlicht --- src/mapblock.cpp | 111 ++++++++++++++++++++++++++----------------------------- 1 file changed, 53 insertions(+), 58 deletions(-) (limited to 'src/mapblock.cpp') diff --git a/src/mapblock.cpp b/src/mapblock.cpp index 7e23d295b..9372c8fb1 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -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; idrop(); mesh = NULL; } - /*for(s32 i=0; idrop(); - 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 &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. -- cgit v1.2.3