]> git.lizzy.rs Git - minetest.git/blobdiff - src/remoteplayer.h
Settings: Fix game minetest.conf flags overriding defaults (#9404)
[minetest.git] / src / remoteplayer.h
index 965dede508f542a57571fde27d71fc95241b8077..831bfe956af7b21cb022be99b35ed29562c2ebab 100644 (file)
@@ -18,8 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
-#ifndef REMOTEPLAYER_HEADER
-#define REMOTEPLAYER_HEADER
+#pragma once
 
 #include "player.h"
 #include "cloudparams.h"
@@ -42,7 +41,7 @@ class RemotePlayer : public Player
 
 public:
        RemotePlayer(const char *name, IItemDefManager *idef);
-       virtual ~RemotePlayer() {}
+       virtual ~RemotePlayer() = default;
 
        void deSerialize(std::istream &is, const std::string &playername, PlayerSAO *sao);
 
@@ -72,7 +71,7 @@ class RemotePlayer : public Player
 
        void setHotbarImage(const std::string &name) { hud_hotbar_image = name; }
 
-       std::string getHotbarImage() const { return hud_hotbar_image; }
+       const std::string &getHotbarImage() const { return hud_hotbar_image; }
 
        void setHotbarSelectedImage(const std::string &name)
        {
@@ -111,12 +110,7 @@ class RemotePlayer : public Player
 
        bool checkModified() const { return m_dirty || inventory.checkModified(); }
 
-       void setModified(const bool x)
-       {
-               m_dirty = x;
-               if (!x)
-                       inventory.setModified(x);
-       }
+       inline void setModified(const bool x) { m_dirty = x; }
 
        void setLocalAnimations(v2s32 frames[4], float frame_speed)
        {
@@ -136,6 +130,15 @@ class RemotePlayer : public Player
 
        u16 protocol_version = 0;
 
+       // v1 for clients older than 5.1.0-dev
+       u16 formspec_version = 1;
+
+       session_t getPeerId() const { return m_peer_id; }
+
+       void setPeerId(session_t peer_id) { m_peer_id = peer_id; }
+
+       void onSuccessfulSave();
+
 private:
        /*
                serialize() writes a bunch of text that can contain
@@ -156,7 +159,7 @@ class RemotePlayer : public Player
        float m_chat_message_allowance = 5.0f;
        u16 m_message_rate_overhead = 0;
 
-       bool m_day_night_ratio_do_override;
+       bool m_day_night_ratio_do_override = false;
        float m_day_night_ratio;
        std::string hud_hotbar_image = "";
        std::string hud_hotbar_selected_image = "";
@@ -167,6 +170,6 @@ class RemotePlayer : public Player
        bool m_sky_clouds;
 
        CloudParams m_cloud_params;
-};
 
-#endif
+       session_t m_peer_id = PEER_ID_INEXISTENT;
+};