Add cancel button to password change menu. (#5720)
[oweals/minetest.git] / src / serverenvironment.h
index d71d29a9cc0f9f5dc5d9b2b65497d4097b723d1e..0e31aa41a2b0727f77a69428c3be899bbd9f0dca 100644 (file)
@@ -21,16 +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 GameScripting;
+class ServerScripting;
 
 /*
        {Active, Loading} block modifier interface.
@@ -191,7 +196,7 @@ typedef UNORDERED_MAP<u16, ServerActiveObject *> ActiveObjectMap;
 class ServerEnvironment : public Environment
 {
 public:
-       ServerEnvironment(ServerMap *map, GameScripting *scriptIface,
+       ServerEnvironment(ServerMap *map, ServerScripting *scriptIface,
                Server *server, const std::string &path_world);
        ~ServerEnvironment();
 
@@ -200,7 +205,7 @@ public:
        ServerMap & getServerMap();
 
        //TODO find way to remove this fct!
-       GameScripting* getScriptIface()
+       ServerScripting* getScriptIface()
        { return m_script; }
 
        Server *getGameDef()
@@ -214,9 +219,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
@@ -317,7 +324,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; }
@@ -331,8 +338,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
                -------------------------------------------
@@ -378,7 +390,7 @@ private:
        // The map
        ServerMap *m_map;
        // Lua state
-       GameScripting* m_script;
+       ServerScripting* m_script;
        // Server definition
        Server *m_server;
        // World path
@@ -416,6 +428,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;