From af7d50e91091b7bec74d94ad61c948062d4c1aab Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 21 May 2011 14:28:58 +0300 Subject: Fixed a small memory leak in ServerEnvironment and cleaned the code a bit --- src/environment.h | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'src/environment.h') diff --git a/src/environment.h b/src/environment.h index 2d3feaca8..971ded5c9 100644 --- a/src/environment.h +++ b/src/environment.h @@ -117,7 +117,7 @@ public: ServerActiveObject* getActiveObject(u16 id); /* - Adds an active object to the environment. + Add an active object to the environment. Environment handles deletion of object. Object may be deleted by environment immediately. If id of object is 0, assigns a free id to it. @@ -127,7 +127,7 @@ public: u16 addActiveObject(ServerActiveObject *object); /* - Finds out what new objects have been added to + Find out what new objects have been added to inside a radius around a position */ void getAddedActiveObjects(v3s16 pos, s16 radius, @@ -135,7 +135,7 @@ public: core::map &added_objects); /* - Finds out what new objects have been removed from + Find out what new objects have been removed from inside a radius around a position */ void getRemovedActiveObjects(v3s16 pos, s16 radius, @@ -143,12 +143,28 @@ public: core::map &removed_objects); /* - Gets the next message emitted by some active object. + Get the next message emitted by some active object. Returns a message with id=0 if no messages are available. */ ActiveObjectMessage getActiveObjectMessage(); - + private: + /* + Remove all objects that satisfy (m_removed && m_known_by_count==0) + */ + void removeRemovedObjects(); + /* + Convert stored objects from blocks near the players to active. + */ + void activateNearObjects(s16 range_blocks); + /* + Convert objects that are far away from all the players to static. + + If range_blocks == -1, convert everything to static even if known + by a player. + */ + void deactivateFarObjects(s16 range_blocks); + ServerMap *m_map; Server *m_server; core::map m_active_objects; -- cgit v1.2.3