LocalPlayer::accelerateHorizontal: cleanups
[oweals/minetest.git] / src / serverenvironment.h
index 0e31aa41a2b0727f77a69428c3be899bbd9f0dca..4cfe7f7d646ee44404e454313500f0e28a694852 100644 (file)
@@ -51,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
@@ -71,7 +70,7 @@ public:
 struct ABMWithState
 {
        ActiveBlockModifier *abm;
-       float timer;
+       float timer = 0.0f;
 
        ABMWithState(ActiveBlockModifier *abm_);
 };
@@ -81,7 +80,7 @@ struct LoadingBlockModifierDef
        // Set of contents to trigger on
        std::set<std::string> trigger_contents;
        std::string name;
-       bool run_at_every_load;
+       bool run_at_every_load = false;
 
        virtual ~LoadingBlockModifierDef() {}
        virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n){};
@@ -89,8 +88,8 @@ struct LoadingBlockModifierDef
 
 struct LBMContentMapping
 {
-       typedef std::map<content_t, std::vector<LoadingBlockModifierDef *> > container_map;
-       container_map map;
+       typedef std::unordered_map<content_t, std::vector<LoadingBlockModifierDef *>> lbm_map;
+       lbm_map map;
 
        std::vector<LoadingBlockModifierDef *> lbm_list;
 
@@ -105,10 +104,7 @@ struct LBMContentMapping
 class LBMManager
 {
 public:
-       LBMManager():
-               m_query_mode(false)
-       {}
-
+       LBMManager() {}
        ~LBMManager();
 
        // Don't call this after loadIntroductionTimes() ran.
@@ -129,7 +125,7 @@ public:
 private:
        // Once we set this to true, we can only query,
        // not modify
-       bool m_query_mode;
+       bool m_query_mode = false;
 
        // For m_query_mode == false:
        // The key of the map is the LBM def's name.
@@ -191,7 +187,7 @@ enum ClearObjectsMode {
        This is not thread-safe. Server uses an environment mutex.
 */
 
-typedef UNORDERED_MAP<u16, ServerActiveObject *> ActiveObjectMap;
+typedef std::unordered_map<u16, ServerActiveObject *> ServerActiveObjectMap;
 
 class ServerEnvironment : public Environment
 {
@@ -288,6 +284,11 @@ public:
        */
        ActiveObjectMessage getActiveObjectMessage();
 
+       virtual void getSelectedActiveObjects(
+               const core::line3d<f32> &shootline_on_map,
+               std::vector<PointedThing> &objects
+       );
+
        /*
                Activate objects and dynamically modify for the dtime determined
                from timestamp and additional_dtime
@@ -396,44 +397,44 @@ private:
        // World path
        const std::string m_path_world;
        // Active object list
-       ActiveObjectMap m_active_objects;
+       ServerActiveObjectMap m_active_objects;
        // Outgoing network message buffer for active objects
        std::queue<ActiveObjectMessage> m_active_object_messages;
        // Some timers
-       float m_send_recommended_timer;
+       float m_send_recommended_timer = 0.0f;
        IntervalLimiter m_object_management_interval;
        // List of active blocks
        ActiveBlockList m_active_blocks;
        IntervalLimiter m_active_blocks_management_interval;
        IntervalLimiter m_active_block_modifier_interval;
        IntervalLimiter m_active_blocks_nodemetadata_interval;
-       int m_active_block_interval_overload_skip;
+       int m_active_block_interval_overload_skip = 0;
        // Time from the beginning of the game in seconds.
        // Incremented in step().
-       u32 m_game_time;
+       u32 m_game_time = 0;
        // A helper variable for incrementing the latter
-       float m_game_time_fraction_counter;
+       float m_game_time_fraction_counter = 0.0f;
        // Time of last clearObjects call (game time).
        // When a mapblock older than this is loaded, its objects are cleared.
-       u32 m_last_clear_objects_time;
+       u32 m_last_clear_objects_time = 0;
        // Active block modifiers
        std::vector<ABMWithState> m_abms;
        LBMManager m_lbm_mgr;
        // An interval for generally sending object positions and stuff
-       float m_recommended_send_interval;
+       float m_recommended_send_interval = 0.1f;
        // 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;
+       float m_max_lag_estimate = 0.1f;
 
        // peer_ids in here should be unique, except that there may be many 0s
        std::vector<RemotePlayer*> m_players;
 
-       PlayerDatabase *m_player_database;
+       PlayerDatabase *m_player_database = nullptr;
 
        // Particles
        IntervalLimiter m_particle_management_interval;
-       UNORDERED_MAP<u32, float> m_particle_spawners;
-       UNORDERED_MAP<u32, u16> m_particle_spawner_attachments;
+       std::unordered_map<u32, float> m_particle_spawners;
+       std::unordered_map<u32, u16> m_particle_spawner_attachments;
 };
 
 #endif