3 Copyright (C) 2010-2016 celeron55, Perttu Ahola <celeron55@gmail.com>
4 Copyright (C) 2014-2016 nerzhul, Loic Blot <loic.blot@unix-experience.fr>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include "cloudparams.h"
28 enum RemotePlayerChatResult
30 RPLAYER_CHATRESULT_OK,
31 RPLAYER_CHATRESULT_FLOODING,
32 RPLAYER_CHATRESULT_KICK,
38 class RemotePlayer : public Player
40 friend class PlayerDatabaseFiles;
43 RemotePlayer(const char *name, IItemDefManager *idef);
44 virtual ~RemotePlayer() = default;
46 void deSerialize(std::istream &is, const std::string &playername, PlayerSAO *sao);
48 PlayerSAO *getPlayerSAO() { return m_sao; }
49 void setPlayerSAO(PlayerSAO *sao) { m_sao = sao; }
51 const RemotePlayerChatResult canSendChatMessage();
53 void setHotbarItemcount(s32 hotbar_itemcount)
55 hud_hotbar_itemcount = hotbar_itemcount;
58 s32 getHotbarItemcount() const { return hud_hotbar_itemcount; }
60 void overrideDayNightRatio(bool do_override, float ratio)
62 m_day_night_ratio_do_override = do_override;
63 m_day_night_ratio = ratio;
66 void getDayNightRatio(bool *do_override, float *ratio)
68 *do_override = m_day_night_ratio_do_override;
69 *ratio = m_day_night_ratio;
72 void setHotbarImage(const std::string &name) { hud_hotbar_image = name; }
74 const std::string &getHotbarImage() const { return hud_hotbar_image; }
76 void setHotbarSelectedImage(const std::string &name)
78 hud_hotbar_selected_image = name;
81 const std::string &getHotbarSelectedImage() const
83 return hud_hotbar_selected_image;
86 void setSky(const video::SColor &bgcolor, const std::string &type,
87 const std::vector<std::string> ¶ms, bool &clouds)
89 m_sky_bgcolor = bgcolor;
91 m_sky_params = params;
92 m_sky_clouds = clouds;
95 void getSky(video::SColor *bgcolor, std::string *type,
96 std::vector<std::string> *params, bool *clouds)
98 *bgcolor = m_sky_bgcolor;
100 *params = m_sky_params;
101 *clouds = m_sky_clouds;
104 void setCloudParams(const CloudParams &cloud_params)
106 m_cloud_params = cloud_params;
109 const CloudParams &getCloudParams() const { return m_cloud_params; }
111 bool checkModified() const { return m_dirty || inventory.checkModified(); }
113 void setModified(const bool x)
117 inventory.setModified(x);
120 void setLocalAnimations(v2s32 frames[4], float frame_speed)
122 for (int i = 0; i < 4; i++)
123 local_animations[i] = frames[i];
124 local_animation_speed = frame_speed;
127 void getLocalAnimations(v2s32 *frames, float *frame_speed)
129 for (int i = 0; i < 4; i++)
130 frames[i] = local_animations[i];
131 *frame_speed = local_animation_speed;
134 void setDirty(bool dirty) { m_dirty = true; }
136 u16 protocol_version = 0;
138 session_t getPeerId() const { return m_peer_id; }
140 void setPeerId(session_t peer_id) { m_peer_id = peer_id; }
144 serialize() writes a bunch of text that can contain
145 any characters except a '\0', and such an ending that
146 deSerialize stops reading exactly at the right point.
148 void serialize(std::ostream &os);
149 void serializeExtraAttributes(std::string &output);
151 PlayerSAO *m_sao = nullptr;
152 bool m_dirty = false;
154 static bool m_setting_cache_loaded;
155 static float m_setting_chat_message_limit_per_10sec;
156 static u16 m_setting_chat_message_limit_trigger_kick;
158 u32 m_last_chat_message_sent = std::time(0);
159 float m_chat_message_allowance = 5.0f;
160 u16 m_message_rate_overhead = 0;
162 bool m_day_night_ratio_do_override = false;
163 float m_day_night_ratio;
164 std::string hud_hotbar_image = "";
165 std::string hud_hotbar_selected_image = "";
167 std::string m_sky_type;
168 video::SColor m_sky_bgcolor;
169 std::vector<std::string> m_sky_params;
172 CloudParams m_cloud_params;
174 session_t m_peer_id = PEER_ID_INEXISTENT;