aboutsummaryrefslogtreecommitdiff
path: root/src/environment.cpp
diff options
context:
space:
mode:
authorSmallJoker <mk939@ymail.com>2014-11-08 14:35:55 +0100
committerKahrl <kahrl@gmx.net>2014-11-08 14:56:09 +0100
commitc40e993ce4a13321e57856fb40566fa93a5ef187 (patch)
tree27049ec2f527c06907ff1631d74843cb7e7164fa /src/environment.cpp
parent96fcca4ea0a9ac0cec1ef48d5baeed78120f62e9 (diff)
downloadminetest-c40e993ce4a13321e57856fb40566fa93a5ef187.tar.gz
minetest-c40e993ce4a13321e57856fb40566fa93a5ef187.tar.bz2
minetest-c40e993ce4a13321e57856fb40566fa93a5ef187.zip
Replace setting unlimited_player_transfer_distance with player_transfer_distance
Diffstat (limited to 'src/environment.cpp')
-rw-r--r--src/environment.cpp41
1 files changed, 26 insertions, 15 deletions
diff --git a/src/environment.cpp b/src/environment.cpp
index 64c998671..01a7e38dc 100644
--- a/src/environment.cpp
+++ b/src/environment.cpp
@@ -1345,11 +1345,17 @@ bool ServerEnvironment::addActiveObjectAsStatic(ServerActiveObject *obj)
inside a radius around a position
*/
void ServerEnvironment::getAddedActiveObjects(v3s16 pos, s16 radius,
+ s16 player_radius,
std::set<u16> &current_objects,
std::set<u16> &added_objects)
{
v3f pos_f = intToFloat(pos, BS);
f32 radius_f = radius * BS;
+ f32 player_radius_f = player_radius * BS;
+
+ if (player_radius_f < 0)
+ player_radius_f = 0;
+
/*
Go through the object list,
- discard m_removed objects,
@@ -1369,12 +1375,15 @@ void ServerEnvironment::getAddedActiveObjects(v3s16 pos, s16 radius,
// Discard if removed or deactivating
if(object->m_removed || object->m_pending_deactivation)
continue;
- if(object->unlimitedTransferDistance() == false){
+
+ f32 distance_f = object->getBasePosition().getDistanceFrom(pos_f);
+ if (object->getType() == ACTIVEOBJECT_TYPE_PLAYER) {
// Discard if too far
- f32 distance_f = object->getBasePosition().getDistanceFrom(pos_f);
- if(distance_f > radius_f)
+ if (distance_f > player_radius_f && player_radius_f != 0)
continue;
- }
+ } else if (distance_f > radius_f)
+ continue;
+
// Discard if already on current_objects
std::set<u16>::iterator n;
n = current_objects.find(id);
@@ -1390,11 +1399,17 @@ void ServerEnvironment::getAddedActiveObjects(v3s16 pos, s16 radius,
inside a radius around a position
*/
void ServerEnvironment::getRemovedActiveObjects(v3s16 pos, s16 radius,
+ s16 player_radius,
std::set<u16> &current_objects,
std::set<u16> &removed_objects)
{
v3f pos_f = intToFloat(pos, BS);
f32 radius_f = radius * BS;
+ f32 player_radius_f = player_radius * BS;
+
+ if (player_radius_f < 0)
+ player_radius_f = 0;
+
/*
Go through current_objects; object is removed if:
- object is not found in m_active_objects (this is actually an
@@ -1423,19 +1438,15 @@ void ServerEnvironment::getRemovedActiveObjects(v3s16 pos, s16 radius,
continue;
}
- // If transfer distance is unlimited, don't remove
- if(object->unlimitedTransferDistance())
- continue;
-
f32 distance_f = object->getBasePosition().getDistanceFrom(pos_f);
-
- if(distance_f >= radius_f)
- {
- removed_objects.insert(id);
+ if (object->getType() == ACTIVEOBJECT_TYPE_PLAYER) {
+ if (distance_f <= player_radius_f || player_radius_f == 0)
+ continue;
+ } else if (distance_f <= radius_f)
continue;
- }
-
- // Not removed
+
+ // Object is no longer visible
+ removed_objects.insert(id);
}
}