1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-17 17:08:39 +00:00

Add an activeobject manager to hold active objects (#7939)

* Add an activeobject manager to hold active objects
* Add unittests
This commit is contained in:
Loïc Blot 2018-12-13 20:18:54 +01:00 committed by GitHub
parent 839e935ba0
commit eda35100b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 844 additions and 320 deletions

View file

@ -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