]> git.lizzy.rs Git - minetest.git/blobdiff - src/environment.h
Fix memory leaks due to messed up memory handling for particles as well as their...
[minetest.git] / src / environment.h
index 5062b9c370e79bd66fb0e6985b34fe692fd36b67..03c21b08ccff55aad7963da7e003876ddf4f8d59 100644 (file)
@@ -38,6 +38,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "util/numeric.h"
 #include "mapnode.h"
 #include "mapblock.h"
+#include "jthread/jmutex.h"
 
 class ServerEnvironment;
 class ActiveBlockModifier;
@@ -69,6 +70,7 @@ class Environment
 
        virtual void addPlayer(Player *player);
        void removePlayer(u16 peer_id);
+       void removePlayer(const char *name);
        Player * getPlayer(u16 peer_id);
        Player * getPlayer(const char *name);
        Player * getRandomConnectedPlayer();
@@ -93,11 +95,9 @@ class Environment
 
        void stepTimeOfDay(float dtime);
 
-       void setTimeOfDaySpeed(float speed)
-       { m_time_of_day_speed = speed; }
+       void setTimeOfDaySpeed(float speed);
        
-       float getTimeOfDaySpeed()
-       { return m_time_of_day_speed; }
+       float getTimeOfDaySpeed();
 
        void setDayNightRatioOverride(bool enable, u32 value)
        {
@@ -122,6 +122,20 @@ class Environment
        bool m_enable_day_night_ratio_override;
        u32 m_day_night_ratio_override;
 
+       /* TODO: Add a callback function so these can be updated when a setting
+        *       changes.  At this point in time it doesn't matter (e.g. /set
+        *       is documented to change server settings only)
+        *
+        * TODO: Local caching of settings is not optimal and should at some stage
+        *       be updated to use a global settings object for getting thse values
+        *       (as opposed to the this local caching). This can be addressed in
+        *       a later release.
+        */
+       bool m_cache_enable_shaders;
+       
+private:
+       JMutex m_lock;
+
 };
 
 /*
@@ -197,7 +211,7 @@ class ServerEnvironment : public Environment
 {
 public:
        ServerEnvironment(ServerMap *map, GameScripting *scriptIface,
-                       IGameDef *gamedef);
+                       IGameDef *gamedef, const std::string &path_world);
        ~ServerEnvironment();
 
        Map & getMap();
@@ -214,17 +228,16 @@ class ServerEnvironment : public Environment
        float getSendRecommendedInterval()
                { return m_recommended_send_interval; }
 
-       /*
-               Save players
-       */
-       void serializePlayers(const std::string &savedir);
-       void deSerializePlayers(const std::string &savedir);
+       // Save players
+       void saveLoadedPlayers();
+       void savePlayer(const std::string &playername);
+       Player *loadPlayer(const std::string &playername);
 
        /*
                Save and load time of day and game timer
        */
-       void saveMeta(const std::string &savedir);
-       void loadMeta(const std::string &savedir);
+       void saveMeta();
+       void loadMeta();
 
        /*
                External ActiveObject interface
@@ -257,6 +270,7 @@ class ServerEnvironment : public Environment
                inside a radius around a position
        */
        void getAddedActiveObjects(v3s16 pos, s16 radius,
+                       s16 player_radius,
                        std::set<u16> &current_objects,
                        std::set<u16> &added_objects);
 
@@ -265,6 +279,7 @@ class ServerEnvironment : public Environment
                inside a radius around a position
        */
        void getRemovedActiveObjects(v3s16 pos, s16 radius,
+                       s16 player_radius,
                        std::set<u16> &current_objects,
                        std::set<u16> &removed_objects);
        
@@ -366,6 +381,8 @@ class ServerEnvironment : public Environment
        GameScripting* m_script;
        // Game definition
        IGameDef *m_gamedef;
+       // World path
+       const std::string m_path_world;
        // Active object list
        std::map<u16, ServerActiveObject*> m_active_objects;
        // Outgoing network message buffer for active objects
@@ -492,7 +509,7 @@ class ClientEnvironment : public Environment
        // Get event from queue. CEE_NONE is returned if queue is empty.
        ClientEnvEvent getClientEvent();
 
-       std::vector<core::vector2d<int> > attachment_list; // X is child ID, Y is parent ID
+       u16 m_attachements[USHRT_MAX];
 
        std::list<std::string> getPlayerNames()
        { return m_player_names; }