diff --git a/src/game.cpp b/src/game.cpp index 265a92f..67db8a1 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -346,9 +346,8 @@ PointedThing getPointedThing(Client *client, v3f player_position, // That didn't work, try to find a pointed at node - static const bool extBlockSel = g_settings->getBool("extended_block_selecting"); - bool onlyFreeFound = false; - bool freeNodeFound = false; + static const bool ext_block_sel = g_settings->getBool("extended_block_selecting"); + bool free_node_found = false; f32 mindistance = BS * 1001; //used for regular blocks f32 maxdistance = -BS * 1001; //used for free blocks @@ -576,7 +575,7 @@ PointedThing getPointedThing(Client *client, v3f player_position, should_show_hilightbox = true; //if no node has been found - we try to find 'fake' pointed node - }else if(extBlockSel + }else if(ext_block_sel && result.type == POINTEDTHING_NOTHING && distance < (BS*6) //is this enough? && np != pos_i @@ -598,10 +597,10 @@ PointedThing getPointedThing(Client *client, v3f player_position, continue; //check if we can build onto this node by normally selecting it - if( npos.X==camdir_i.X //is it same direction as camera? + if( npos.X==camdir_i.X //check if it's the same direction as camera || npos.Y==camdir_i.Y || npos.Z==camdir_i.Z - || (npos.X != 0 && cam_i.X == np.X) //is it the same axis as camera? + || (npos.X != 0 && cam_i.X == np.X) //check if it's the same axis as camera || (npos.Y != 0 && cam_i.Y == np.Y) || (npos.Z != 0 && cam_i.Z == np.Z) ) { @@ -619,10 +618,10 @@ PointedThing getPointedThing(Client *client, v3f player_position, maxdistance = distance; - //result.type = POINTEDTHING_NODE; //we can't do this here! - freeNodeFound = true; //instead, we set this and check at the end + //result.type = POINTEDTHING_NODE; //we can't do this here + free_node_found = true; //instead, we set this and check at the end - result.node_undersurface = neigh_pos; //yes, these are swaped! + result.node_undersurface = neigh_pos; //yes, these are swaped result.node_abovesurface = np; const float d = 0.502; @@ -641,7 +640,7 @@ PointedThing getPointedThing(Client *client, v3f player_position, } // regular block } // for coords - if(extBlockSel && result.type == POINTEDTHING_NOTHING && freeNodeFound){ + if(ext_block_sel && result.type == POINTEDTHING_NOTHING && free_node_found){ result.is_fake = true; result.type = POINTEDTHING_NODE; should_show_hilightbox = true; diff --git a/src/player.cpp b/src/player.cpp index 8afdb95..95d45a2 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -31,8 +31,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "environment.h" #include "gamedef.h" -f32 Player::m_eyeOffsetMax = BS+(5*BS)/8; -f32 Player::m_eyeOffsetMin = BS * 0.9f; +#define EYE_OFFSET_MAX (BS+(5*BS)/8) +#define EYE_OFFSET_MIN (BS * 0.9f) Player::Player(IGameDef *gamedef): touching_ground(false), @@ -51,7 +51,7 @@ Player::Player(IGameDef *gamedef): m_yaw(0), m_speed(0,0,0), m_position(0,0,0), - m_eyeOffset(0,m_eyeOffsetMax,0) + m_eye_offset(0,EYE_OFFSET_MAX,0) { updateName(""); resetInventory(); @@ -294,8 +294,8 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d, assert(d > pos_max_d); float player_radius = BS*0.35; - float player_height = m_eyeOffset.Y + BS*0.05f; - float player_maxheight = m_eyeOffsetMax + BS*0.05f; + float player_height = m_eye_offset.Y + BS*0.05f; + float player_maxheight = EYE_OFFSET_MAX + BS*0.05f; // Maximum distance over border for sneaking f32 sneak_max = BS*0.4; @@ -603,7 +603,7 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d, Check if player must crawl */ bool must_crawl = false; - v3s16 pos_head_i = floatToInt(v3f(position.X,position.Y+m_eyeOffsetMax+BS*0.05f,position.Z), BS); + v3s16 pos_head_i = floatToInt(v3f(position.X,position.Y+EYE_OFFSET_MAX+BS*0.05f,position.Z), BS); for(s16 z = -1; z <= 1; z++) for(s16 x = -1; x <= 1; x++) { @@ -613,8 +613,8 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d, if(nodemgr->get(map.getNode(np)).walkable == false) continue; core::aabbox3d nodebox = getNodeBox(np, BS); - if( (m_must_crawl || control.crawl) //shall we test it? - && playerbox_standing.intersectsWithBox(nodebox) //colliding with the node? + if( (m_must_crawl || control.crawl) //only if we were crawling before + && playerbox_standing.intersectsWithBox(nodebox) //only when colliding with the node ) { must_crawl = true; @@ -798,14 +798,14 @@ void LocalPlayer::applyControl(float dtime) static const f32 eyes_delta = 10.f; if(control.crawl){ //crawling - if(m_eyeOffset.Y > m_eyeOffsetMin + 0.01f) - m_eyeOffset.Y += (m_eyeOffsetMin-m_eyeOffset.Y) * eyes_delta * dtime; - else m_eyeOffset.Y = m_eyeOffsetMin; + if(m_eye_offset.Y > EYE_OFFSET_MIN + 0.01f) + m_eye_offset.Y += (EYE_OFFSET_MIN-m_eye_offset.Y) * eyes_delta * dtime; + else m_eye_offset.Y = EYE_OFFSET_MIN; }else{ //standing - if(m_eyeOffset.Y < m_eyeOffsetMax - 0.01f) - m_eyeOffset.Y += (m_eyeOffsetMax-m_eyeOffset.Y) * eyes_delta * dtime; - else m_eyeOffset.Y = m_eyeOffsetMax; + if(m_eye_offset.Y < EYE_OFFSET_MAX - 0.01f) + m_eye_offset.Y += (EYE_OFFSET_MAX-m_eye_offset.Y) * eyes_delta * dtime; + else m_eye_offset.Y = EYE_OFFSET_MAX; } } #endif diff --git a/src/player.h b/src/player.h index 21ecf10..f31dca8 100644 --- a/src/player.h +++ b/src/player.h @@ -70,7 +70,7 @@ public: // return v3f(0, BS+BS/2, 0); // This is more like in minecraft //return v3f(0,BS+(5*BS)/8,0); - return m_eyeOffset; + return m_eye_offset; } v3f getEyePosition() @@ -170,9 +170,7 @@ protected: f32 m_yaw; v3f m_speed; v3f m_position; - v3f m_eyeOffset; - static f32 m_eyeOffsetMax; - static f32 m_eyeOffsetMin; + v3f m_eye_offset; public: diff --git a/src/utility.cpp b/src/utility.cpp index f2a4cbc..308fcbc 100644 --- a/src/utility.cpp +++ b/src/utility.cpp @@ -274,9 +274,9 @@ std::string PointedThing::dump() const { const v3s16 &u = node_undersurface; const v3s16 &a = node_abovesurface; - os<<"[node under="<