Tooltips: Unify the tooltip[] and list[] description tooltip display functions (...
[oweals/minetest.git] / src / serverenvironment.h
index 20a783ea54385381f2489ad1396a58238344b9de..7c370fd5495cedc725e6433d45b3a3ba7998a669 100644 (file)
@@ -21,14 +21,21 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #define SERVER_ENVIRONMENT_HEADER
 
 #include "environment.h"
+#include "mapnode.h"
+#include "mapblock.h"
+#include <set>
 
 class IGameDef;
 class ServerMap;
+struct GameParams;
 class RemotePlayer;
+class PlayerDatabase;
 class PlayerSAO;
 class ServerEnvironment;
 class ActiveBlockModifier;
 class ServerActiveObject;
+class Server;
+class ServerScripting;
 
 /*
        {Active, Loading} block modifier interface.
@@ -44,11 +51,10 @@ public:
        virtual ~ActiveBlockModifier(){};
 
        // Set of contents to trigger on
-       virtual std::set<std::string> getTriggerContents()=0;
+       virtual const std::set<std::string> &getTriggerContents() const = 0;
        // Set of required neighbors (trigger doesn't happen if none are found)
        // Empty = do not check neighbors
-       virtual std::set<std::string> getRequiredNeighbors()
-       { return std::set<std::string>(); }
+       virtual const std::set<std::string> &getRequiredNeighbors() const = 0;
        // Trigger interval in seconds
        virtual float getTriggerInterval() = 0;
        // Random chance of (1 / return value), 0 is disallowed
@@ -189,8 +195,8 @@ typedef UNORDERED_MAP<u16, ServerActiveObject *> ActiveObjectMap;
 class ServerEnvironment : public Environment
 {
 public:
-       ServerEnvironment(ServerMap *map, GameScripting *scriptIface,
-               IGameDef *gamedef, const std::string &path_world);
+       ServerEnvironment(ServerMap *map, ServerScripting *scriptIface,
+               Server *server, const std::string &path_world);
        ~ServerEnvironment();
 
        Map & getMap();
@@ -198,11 +204,11 @@ public:
        ServerMap & getServerMap();
 
        //TODO find way to remove this fct!
-       GameScripting* getScriptIface()
+       ServerScripting* getScriptIface()
        { return m_script; }
 
-       IGameDef *getGameDef()
-       { return m_gamedef; }
+       Server *getGameDef()
+       { return m_server; }
 
        float getSendRecommendedInterval()
        { return m_recommended_send_interval; }
@@ -212,9 +218,11 @@ public:
        // Save players
        void saveLoadedPlayers();
        void savePlayer(RemotePlayer *player);
-       RemotePlayer *loadPlayer(const std::string &playername, PlayerSAO *sao);
+       PlayerSAO *loadPlayer(RemotePlayer *player, bool *new_player, u16 peer_id,
+               bool is_singleplayer);
        void addPlayer(RemotePlayer *player);
        void removePlayer(RemotePlayer *player);
+       bool removePlayerFromDatabase(const std::string &name);
 
        /*
                Save and load time of day and game timer
@@ -315,7 +323,7 @@ public:
        //check if there's a line of sight between two positions
        bool line_of_sight(v3f pos1, v3f pos2, float stepsize=1.0, v3s16 *p=NULL);
 
-       u32 getGameTime() { return m_game_time; }
+       u32 getGameTime() const { return m_game_time; }
 
        void reportMaxLagEstimate(float f) { m_max_lag_estimate = f; }
        float getMaxLagEstimate() { return m_max_lag_estimate; }
@@ -329,8 +337,13 @@ public:
 
        RemotePlayer *getPlayer(const u16 peer_id);
        RemotePlayer *getPlayer(const char* name);
+
+       static bool migratePlayersDatabase(const GameParams &game_params,
+                       const Settings &cmd_args);
 private:
 
+       static PlayerDatabase *openPlayerDatabase(const std::string &name,
+                       const std::string &savedir, const Settings &conf);
        /*
                Internal ActiveObject interface
                -------------------------------------------
@@ -376,9 +389,9 @@ private:
        // The map
        ServerMap *m_map;
        // Lua state
-       GameScripting* m_script;
-       // Game definition
-       IGameDef *m_gamedef;
+       ServerScripting* m_script;
+       // Server definition
+       Server *m_server;
        // World path
        const std::string m_path_world;
        // Active object list
@@ -414,6 +427,8 @@ private:
        // peer_ids in here should be unique, except that there may be many 0s
        std::vector<RemotePlayer*> m_players;
 
+       PlayerDatabase *m_player_database;
+
        // Particles
        IntervalLimiter m_particle_management_interval;
        UNORDERED_MAP<u32, float> m_particle_spawners;