mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-17 17:08:39 +00:00
scriptapi: Sort out ServerEnvironment / Environment distinction properly
The API implementation is shared between CSM and SSM. Functions should retrieve a plain env when they do not need any server-specific functions.
This commit is contained in:
parent
f105bc8dc2
commit
054c5dfaa3
7 changed files with 72 additions and 65 deletions
|
@ -83,6 +83,24 @@ float Environment::getTimeOfDayF()
|
|||
return m_time_of_day_f;
|
||||
}
|
||||
|
||||
bool Environment::line_of_sight(v3f pos1, v3f pos2, v3s16 *p)
|
||||
{
|
||||
// Iterate trough nodes on the line
|
||||
voxalgo::VoxelLineIterator iterator(pos1 / BS, (pos2 - pos1) / BS);
|
||||
do {
|
||||
MapNode n = getMap().getNode(iterator.m_current_node_pos);
|
||||
|
||||
// Return non-air
|
||||
if (n.param0 != CONTENT_AIR) {
|
||||
if (p)
|
||||
*p = iterator.m_current_node_pos;
|
||||
return false;
|
||||
}
|
||||
iterator.next();
|
||||
} while (iterator.m_current_index <= iterator.m_last_index);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
Check if a node is pointable
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue