diff options
author | sfan5 <sfan5@live.de> | 2019-11-09 00:22:42 +0100 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2019-11-11 14:06:48 +0100 |
commit | b57dc70769873e00ca7a7642862eb209a5528ce2 (patch) | |
tree | f0f79e77d7996469350033dc2fe1ef7319133c39 /src/client | |
parent | b0260b5ec8e05e54928f9487bb39b4ff946951f9 (diff) | |
download | minetest-b57dc70769873e00ca7a7642862eb209a5528ce2.tar.gz minetest-b57dc70769873e00ca7a7642862eb209a5528ce2.tar.bz2 minetest-b57dc70769873e00ca7a7642862eb209a5528ce2.zip |
[CSM] Expose more env functions
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); |