aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-12-02 01:08:14 +0200
committerPerttu Ahola <celeron55@gmail.com>2011-12-02 01:08:14 +0200
commite4daa4c0658dc8547352dd2039ab74d963a48ff0 (patch)
treeb9fb32f98a4881649cda09b4eb083de25953ee3b /src
parent08a10b8a6a77eb729d609979ee822134d5d7a645 (diff)
downloadminetest-e4daa4c0658dc8547352dd2039ab74d963a48ff0.tar.gz
minetest-e4daa4c0658dc8547352dd2039ab74d963a48ff0.tar.bz2
minetest-e4daa4c0658dc8547352dd2039ab74d963a48ff0.zip
Make players be again visible from a long distance
Diffstat (limited to 'src')
-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,