]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/environment.h
Revert "Fix settings to honor numeric conversion errors"
[dragonfireclient.git] / src / environment.h
index e175d70d9d2c81ec0c4a2ad43ed683b1c0559b42..ffd4a15541e61fa91e647558780ace04a9e55261 100644 (file)
@@ -32,11 +32,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 #include <set>
 #include <list>
-#include "irrlichttypes_extrabloated.h"
-#include "player.h"
-#include <ostream>
+#include <map>
+#include "irr_v3d.h"
 #include "activeobject.h"
-#include "util/container.h"
 #include "util/numeric.h"
 #include "mapnode.h"
 #include "mapblock.h"
@@ -44,13 +42,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 class ServerEnvironment;
 class ActiveBlockModifier;
 class ServerActiveObject;
-typedef struct lua_State lua_State;
 class ITextureSource;
 class IGameDef;
+class IBackgroundBlockEmerger;
 class Map;
 class ServerMap;
 class ClientMap;
-class ScriptApi;
+class GameScripting;
+class Player;
 
 class Environment
 {
@@ -77,10 +76,9 @@ class Environment
        Player * getNearestConnectedPlayer(v3f pos);
        std::list<Player*> getPlayers();
        std::list<Player*> getPlayers(bool ignore_disconnected);
-       void printPlayers(std::ostream &o);
        
        u32 getDayNightRatio();
-       
+
        // 0-23999
        virtual void setTimeOfDay(u32 time)
        {
@@ -102,6 +100,12 @@ class Environment
        float getTimeOfDaySpeed()
        { return m_time_of_day_speed; }
 
+       void setDayNightRatioOverride(bool enable, u32 value)
+       {
+               m_enable_day_night_ratio_override = enable;
+               m_day_night_ratio_override = value;
+       }
+
 protected:
        // peer_ids in here should be unique, except that there may be many 0s
        std::list<Player*> m_players;
@@ -112,6 +116,9 @@ class Environment
        float m_time_of_day_speed;
        // Used to buffer dtime for adding to m_time_of_day
        float m_time_counter;
+       // Overriding the day-night ratio is useful for custom sky visuals
+       bool m_enable_day_night_ratio_override;
+       u32 m_day_night_ratio_override;
 };
 
 /*
@@ -172,16 +179,11 @@ class ActiveBlockList
        }
 
        std::set<v3s16> m_list;
+       std::set<v3s16> m_forceloaded_list;
 
 private:
 };
 
-class IBackgroundBlockEmerger
-{
-public:
-       virtual void queueBlockEmerge(v3s16 blockpos, bool allow_generate)=0;
-};
-
 /*
        The server-side environment.
 
@@ -191,7 +193,8 @@ class IBackgroundBlockEmerger
 class ServerEnvironment : public Environment
 {
 public:
-       ServerEnvironment(ServerMap *map, ScriptApi *iface, IGameDef *gamedef,
+       ServerEnvironment(ServerMap *map, GameScripting *scriptIface,
+                       IGameDef *gamedef,
                        IBackgroundBlockEmerger *emerger);
        ~ServerEnvironment();
 
@@ -200,7 +203,7 @@ class ServerEnvironment : public Environment
        ServerMap & getServerMap();
 
        //TODO find way to remove this fct!
-       ScriptApi* getScriptIface()
+       GameScripting* getScriptIface()
                { return m_script; }
 
        IGameDef *getGameDef()
@@ -290,6 +293,7 @@ class ServerEnvironment : public Environment
        // Script-aware node setters
        bool setNode(v3s16 p, const MapNode &n);
        bool removeNode(v3s16 p);
+       bool swapNode(v3s16 p, const MapNode &n);
        
        // Find all active objects inside a radius around a point
        std::set<u16> getObjectsInsideRadius(v3f pos, float radius);
@@ -301,8 +305,18 @@ class ServerEnvironment : public Environment
        void step(f32 dtime);
        
        //check if there's a line of sight between two positions
-       bool line_of_sight(v3f pos1, v3f pos2, float stepsize=1.0);
+       bool line_of_sight(v3f pos1, v3f pos2, float stepsize=1.0, v3s16 *p=NULL);
+
+       u32 getGameTime() { return m_game_time; }
 
+       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<v3s16>* getForceloadedBlocks() { return &m_active_blocks.m_forceloaded_list; };
+       
 private:
 
        /*
@@ -350,15 +364,15 @@ class ServerEnvironment : public Environment
        // The map
        ServerMap *m_map;
        // Lua state
-       ScriptApi* m_script;
+       GameScripting* m_script;
        // Game definition
        IGameDef *m_gamedef;
-       // Background block emerger (the server, in practice)
+       // Background block emerger (the EmergeManager, in practice)
        IBackgroundBlockEmerger *m_emerger;
        // Active object list
        std::map<u16, ServerActiveObject*> m_active_objects;
        // Outgoing network message buffer for active objects
-       Queue<ActiveObjectMessage> m_active_object_messages;
+       std::list<ActiveObjectMessage> m_active_object_messages;
        // Some timers
        float m_random_spawn_timer; // used for experimental code
        float m_send_recommended_timer;
@@ -377,6 +391,9 @@ class ServerEnvironment : public Environment
        std::list<ABMWithState> m_abms;
        // An interval for generally sending object positions and stuff
        float m_recommended_send_interval;
+       // Estimate for general maximum lag as determined by server.
+       // Can raise to high values like 15s with eg. map generation mods.
+       float m_max_lag_estimate;
 };
 
 #ifndef SERVER
@@ -496,7 +513,7 @@ class ClientEnvironment : public Environment
        IrrlichtDevice *m_irr;
        std::map<u16, ClientActiveObject*> m_active_objects;
        std::list<ClientSimpleObject*> m_simple_objects;
-       Queue<ClientEnvEvent> m_client_event_queue;
+       std::list<ClientEnvEvent> m_client_event_queue;
        IntervalLimiter m_active_object_light_update_interval;
        IntervalLimiter m_lava_hurt_interval;
        IntervalLimiter m_drowning_interval;