diff options
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/client.cpp | 13 | ||||
-rw-r--r-- | src/client/client.h | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/client/client.cpp b/src/client/client.cpp index 89873ade3..36d4f8df9 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -1337,6 +1337,19 @@ int Client::CSMClampRadius(v3s16 pos, int radius) return std::min<int>(radius, m_csm_restriction_noderange - distance); } +v3s16 Client::CSMClampPos(v3s16 pos) +{ + if (!checkCSMRestrictionFlag(CSMRestrictionFlags::CSM_RF_LOOKUP_NODES)) + return pos; + v3s16 ppos = floatToInt(m_env.getLocalPlayer()->getPosition(), BS); + const int range = m_csm_restriction_noderange; + return v3s16( + core::clamp<int>(pos.X, (int)ppos.X - range, (int)ppos.X + range), + core::clamp<int>(pos.Y, (int)ppos.Y - range, (int)ppos.Y + range), + core::clamp<int>(pos.Z, (int)ppos.Z - range, (int)ppos.Z + range) + ); +} + void Client::addNode(v3s16 p, MapNode n, bool remove_metadata) { //TimeTaker timer1("Client::addNode()"); diff --git a/src/client/client.h b/src/client/client.h index 5f3362509..5144af69f 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -264,6 +264,7 @@ public: // helpers to enforce CSM restrictions MapNode CSMGetNode(v3s16 p, bool *is_valid_position); int CSMClampRadius(v3s16 pos, int radius); + v3s16 CSMClampPos(v3s16 pos); void addNode(v3s16 p, MapNode n, bool remove_metadata = true); |