mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-12 16:15:20 +02:00
[CSM] Expose more env functions
This commit is contained in:
@@ -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()");
|
||||
|
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user