]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/remoteplayer.h
Allow resetting celestial vault elements by leaving its arguments empty (#11922)
[dragonfireclient.git] / src / remoteplayer.h
index 6ecdb2798d932b21b31ff62219353b82658ebada..c8991480b5b95b32bb79f717c791c72dbc6c5a67 100644 (file)
@@ -21,7 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #pragma once
 
 #include "player.h"
-#include "cloudparams.h"
+#include "skyparams.h"
 
 class PlayerSAO;
 
@@ -43,12 +43,10 @@ class RemotePlayer : public Player
        RemotePlayer(const char *name, IItemDefManager *idef);
        virtual ~RemotePlayer() = default;
 
-       void deSerialize(std::istream &is, const std::string &playername, PlayerSAO *sao);
-
        PlayerSAO *getPlayerSAO() { return m_sao; }
        void setPlayerSAO(PlayerSAO *sao) { m_sao = sao; }
 
-       const RemotePlayerChatResult canSendChatMessage();
+       RemotePlayerChatResult canSendChatMessage();
 
        void setHotbarItemcount(s32 hotbar_itemcount)
        {
@@ -71,7 +69,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)
        {
@@ -83,23 +81,24 @@ class RemotePlayer : public Player
                return hud_hotbar_selected_image;
        }
 
-       void setSky(const video::SColor &bgcolor, const std::string &type,
-                       const std::vector<std::string> &params, bool &clouds)
+       void setSky(const SkyboxParams &skybox_params)
        {
-               m_sky_bgcolor = bgcolor;
-               m_sky_type = type;
-               m_sky_params = params;
-               m_sky_clouds = clouds;
+               m_skybox_params = skybox_params;
        }
 
-       void getSky(video::SColor *bgcolor, std::string *type,
-                       std::vector<std::string> *params, bool *clouds)
-       {
-               *bgcolor = m_sky_bgcolor;
-               *type = m_sky_type;
-               *params = m_sky_params;
-               *clouds = m_sky_clouds;
-       }
+       const SkyboxParams &getSkyParams() const { return m_skybox_params; }
+
+       void setSun(const SunParams &sun_params) { m_sun_params = sun_params; }
+
+       const SunParams &getSunParams() const { return m_sun_params; }
+
+       void setMoon(const MoonParams &moon_params) { m_moon_params = moon_params; }
+
+       const MoonParams &getMoonParams() const { return m_moon_params; }
+
+       void setStars(const StarParams &star_params) { m_star_params = star_params; }
+
+       const StarParams &getStarParams() const { return m_star_params; }
 
        void setCloudParams(const CloudParams &cloud_params)
        {
@@ -110,12 +109,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)
        {
@@ -135,19 +129,16 @@ 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; }
 
-private:
-       /*
-               serialize() writes a bunch of text that can contain
-               any characters except a '\0', and such an ending that
-               deSerialize stops reading exactly at the right point.
-       */
-       void serialize(std::ostream &os);
-       void serializeExtraAttributes(std::string &output);
+       void onSuccessfulSave();
 
+private:
        PlayerSAO *m_sao = nullptr;
        bool m_dirty = false;
 
@@ -164,12 +155,12 @@ class RemotePlayer : public Player
        std::string hud_hotbar_image = "";
        std::string hud_hotbar_selected_image = "";
 
-       std::string m_sky_type;
-       video::SColor m_sky_bgcolor;
-       std::vector<std::string> m_sky_params;
-       bool m_sky_clouds;
-
        CloudParams m_cloud_params;
 
+       SkyboxParams m_skybox_params;
+       SunParams m_sun_params;
+       MoonParams m_moon_params;
+       StarParams m_star_params;
+
        session_t m_peer_id = PEER_ID_INEXISTENT;
 };