diff options
author | Loïc Blot <nerzhul@users.noreply.github.com> | 2018-12-13 20:18:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-13 20:18:54 +0100 |
commit | eda35100b6c6f7d9b01c257557147545b563dc74 (patch) | |
tree | e70929e401c91b4af4a40954c4af45ef59708832 /src/serverenvironment.h | |
parent | 839e935ba0572c592a791cc4dd4df4a9f6d2d260 (diff) | |
download | minetest-eda35100b6c6f7d9b01c257557147545b563dc74.tar.gz minetest-eda35100b6c6f7d9b01c257557147545b563dc74.tar.bz2 minetest-eda35100b6c6f7d9b01c257557147545b563dc74.zip |
Add an activeobject manager to hold active objects (#7939)
* Add an activeobject manager to hold active objects
* Add unittests
Diffstat (limited to 'src/serverenvironment.h')
-rw-r--r-- | src/serverenvironment.h | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/src/serverenvironment.h b/src/serverenvironment.h index b7a121adf..b883e0dc5 100644 --- a/src/serverenvironment.h +++ b/src/serverenvironment.h @@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "environment.h" #include "mapnode.h" #include "settings.h" +#include "server/activeobjectmgr.h" #include "util/numeric.h" #include <set> @@ -243,7 +244,10 @@ public: ------------------------------------------- */ - ServerActiveObject* getActiveObject(u16 id); + ServerActiveObject* getActiveObject(u16 id) + { + return m_ao_manager.getActiveObject(id); + } /* Add an active object to the environment. @@ -255,19 +259,6 @@ public: */ u16 addActiveObject(ServerActiveObject *object); - /** - * Verify if id is a free active object id - * @param id - * @return true if slot is free - */ - bool isFreeServerActiveObjectId(u16 id) const; - - /** - * Retrieve the first free ActiveObject ID - * @return free activeobject ID or 0 if none was found - */ - u16 getFreeServerActiveObjectId(); - /* Add an active object as a static object to the corresponding MapBlock. @@ -331,7 +322,10 @@ public: bool swapNode(v3s16 p, const MapNode &n); // Find all active objects inside a radius around a point - void getObjectsInsideRadius(std::vector<u16> &objects, v3f pos, float radius); + void getObjectsInsideRadius(std::vector<u16> &objects, const v3f &pos, float radius) + { + return m_ao_manager.getObjectsInsideRadius(pos, radius, objects); + } // Clear objects, loading and going through every MapBlock void clearObjects(ClearObjectsMode mode); @@ -438,10 +432,10 @@ private: ServerScripting* m_script; // Server definition Server *m_server; + // Active Object Manager + server::ActiveObjectMgr m_ao_manager; // World path const std::string m_path_world; - // Active object list - ServerActiveObjectMap m_active_objects; // Outgoing network message buffer for active objects std::queue<ActiveObjectMessage> m_active_object_messages; // Some timers |