From eda35100b6c6f7d9b01c257557147545b563dc74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Blot?= Date: Thu, 13 Dec 2018 20:18:54 +0100 Subject: Add an activeobject manager to hold active objects (#7939) * Add an activeobject manager to hold active objects * Add unittests --- src/serverenvironment.h | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'src/serverenvironment.h') 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 @@ -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 &objects, v3f pos, float radius); + void getObjectsInsideRadius(std::vector &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 m_active_object_messages; // Some timers -- cgit v1.2.3