aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/environment.cpp45
-rw-r--r--src/player.cpp5
-rw-r--r--src/player.h3
-rw-r--r--src/serverobject.h3
4 files changed, 39 insertions, 17 deletions
diff --git a/src/environment.cpp b/src/environment.cpp
index 17c9ecfff..e8dfebcb3 100644
--- a/src/environment.cpp
+++ b/src/environment.cpp
@@ -1217,10 +1217,12 @@ void ServerEnvironment::getAddedActiveObjects(v3s16 pos, s16 radius,
// Discard if removed
if(object->m_removed)
continue;
- // Discard if too far
- f32 distance_f = object->getBasePosition().getDistanceFrom(pos_f);
- if(distance_f > radius_f)
- continue;
+ if(object->unlimitedTransferDistance() == false){
+ // Discard if too far
+ f32 distance_f = object->getBasePosition().getDistanceFrom(pos_f);
+ if(distance_f > radius_f)
+ continue;
+ }
// Discard if already on current_objects
core::map<u16, bool>::Node *n;
n = current_objects.find(id);
@@ -1255,24 +1257,33 @@ void ServerEnvironment::getRemovedActiveObjects(v3s16 pos, s16 radius,
{
u16 id = i.getNode()->getKey();
ServerActiveObject *object = getActiveObject(id);
- if(object == NULL)
- {
+
+ if(object == NULL){
infostream<<"ServerEnvironment::getRemovedActiveObjects():"
<<" object in current_objects is NULL"<<std::endl;
+ removed_objects.insert(id, false);
+ continue;
}
- else if(object->m_removed == false)
+
+ if(object->m_removed)
{
- f32 distance_f = object->getBasePosition().getDistanceFrom(pos_f);
- /*infostream<<"removed == false"
- <<"distance_f = "<<distance_f
- <<", radius_f = "<<radius_f<<std::endl;*/
- if(distance_f < radius_f)
- {
- // Not removed
- continue;
- }
+ removed_objects.insert(id, false);
+ 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, false);
+ continue;
}
- removed_objects.insert(id, false);
+
+ // Not removed
}
}
diff --git a/src/player.cpp b/src/player.cpp
index 882566896..f22eddfc1 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -242,6 +242,11 @@ void ServerRemotePlayer::removingFromEnvironment()
m_is_in_environment = false;
}
+bool ServerRemotePlayer::unlimitedTransferDistance() const
+{
+ return true;
+}
+
void ServerRemotePlayer::step(float dtime, bool send_recommended)
{
if(send_recommended == false)
diff --git a/src/player.h b/src/player.h
index c9dbe76bb..cfd59d6ca 100644
--- a/src/player.h
+++ b/src/player.h
@@ -216,6 +216,9 @@ public:
bool environmentDeletes() const
{ return false; }
+
+ virtual bool unlimitedTransferDistance() const;
+
bool isStaticAllowed() const
{ return false; }
diff --git a/src/serverobject.h b/src/serverobject.h
index 1386136ce..fd8a51a9e 100644
--- a/src/serverobject.h
+++ b/src/serverobject.h
@@ -63,6 +63,9 @@ public:
// environment
virtual bool environmentDeletes() const
{ return true; }
+
+ virtual bool unlimitedTransferDistance() const
+ { return false; }
// Create a certain type of ServerActiveObject
static ServerActiveObject* create(u8 type,