X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fenvironment.h;h=e8ae044e30ce0d32bab7ffbeebcb03acddf2cded;hb=8852333eb3042580592ade478e5def20f8ed5d4c;hp=d99e27ba4606f1b8875a93c93bd236a0d32f1fad;hpb=0643cef09a741d1e8a7b971f3ae70b45ac8d44bf;p=oweals%2Fminetest.git diff --git a/src/environment.h b/src/environment.h index d99e27ba4..e8ae044e3 100644 --- a/src/environment.h +++ b/src/environment.h @@ -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 @@ public: 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 @@ public: 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) { @@ -121,6 +121,9 @@ protected: // Overriding the day-night ratio is useful for custom sky visuals bool m_enable_day_night_ratio_override; u32 m_day_night_ratio_override; + +private: + JMutex m_lock; }; @@ -197,7 +200,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 +217,16 @@ public: 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 @@ -314,9 +316,6 @@ public: void reportMaxLagEstimate(float f) { m_max_lag_estimate = f; } float getMaxLagEstimate() { return m_max_lag_estimate; } - // is weather active in this environment? - bool m_use_weather; - std::set* getForceloadedBlocks() { return &m_active_blocks.m_forceloaded_list; }; private: @@ -369,12 +368,13 @@ private: GameScripting* m_script; // Game definition IGameDef *m_gamedef; + // World path + const std::string m_path_world; // Active object list std::map m_active_objects; // Outgoing network message buffer for active objects std::list m_active_object_messages; // Some timers - float m_random_spawn_timer; // used for experimental code float m_send_recommended_timer; IntervalLimiter m_object_management_interval; // List of active blocks @@ -496,7 +496,7 @@ public: // Get event from queue. CEE_NONE is returned if queue is empty. ClientEnvEvent getClientEvent(); - std::vector > attachment_list; // X is child ID, Y is parent ID + u16 m_attachements[USHRT_MAX]; std::list getPlayerNames() { return m_player_names; }