#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.
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();
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; }
// 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
//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; }
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
-------------------------------------------
// 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
// 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;