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.
21 #ifndef REMOTEPLAYER_HEADER
22 #define REMOTEPLAYER_HEADER
28 enum RemotePlayerChatResult {
29 RPLAYER_CHATRESULT_OK,
30 RPLAYER_CHATRESULT_FLOODING,
31 RPLAYER_CHATRESULT_KICK,
36 class RemotePlayer : public Player
39 RemotePlayer(const char *name, IItemDefManager *idef);
40 virtual ~RemotePlayer() {}
42 void save(std::string savedir, IGameDef *gamedef);
43 void deSerialize(std::istream &is, const std::string &playername, PlayerSAO *sao);
45 PlayerSAO *getPlayerSAO() { return m_sao; }
46 void setPlayerSAO(PlayerSAO *sao) { m_sao = sao; }
48 const RemotePlayerChatResult canSendChatMessage();
50 void setHotbarItemcount(s32 hotbar_itemcount)
52 hud_hotbar_itemcount = hotbar_itemcount;
55 s32 getHotbarItemcount() const { return hud_hotbar_itemcount; }
57 void overrideDayNightRatio(bool do_override, float ratio)
59 m_day_night_ratio_do_override = do_override;
60 m_day_night_ratio = ratio;
63 void getDayNightRatio(bool *do_override, float *ratio)
65 *do_override = m_day_night_ratio_do_override;
66 *ratio = m_day_night_ratio;
69 void setHotbarImage(const std::string &name)
71 hud_hotbar_image = name;
74 std::string getHotbarImage() const
76 return hud_hotbar_image;
79 void setHotbarSelectedImage(const std::string &name)
81 hud_hotbar_selected_image = name;
84 const std::string &getHotbarSelectedImage() const
86 return hud_hotbar_selected_image;
89 void setSky(const video::SColor &bgcolor, const std::string &type,
90 const std::vector<std::string> ¶ms)
92 m_sky_bgcolor = bgcolor;
94 m_sky_params = params;
97 void getSky(video::SColor *bgcolor, std::string *type,
98 std::vector<std::string> *params)
100 *bgcolor = m_sky_bgcolor;
102 *params = m_sky_params;
105 bool checkModified() const { return m_dirty || inventory.checkModified(); }
107 void setModified(const bool x)
111 inventory.setModified(x);
114 void setLocalAnimations(v2s32 frames[4], float frame_speed)
116 for (int i = 0; i < 4; i++)
117 local_animations[i] = frames[i];
118 local_animation_speed = frame_speed;
121 void getLocalAnimations(v2s32 *frames, float *frame_speed)
123 for (int i = 0; i < 4; i++)
124 frames[i] = local_animations[i];
125 *frame_speed = local_animation_speed;
128 void setDirty(bool dirty) { m_dirty = true; }
130 u16 protocol_version;
133 serialize() writes a bunch of text that can contain
134 any characters except a '\0', and such an ending that
135 deSerialize stops reading exactly at the right point.
137 void serialize(std::ostream &os);
142 static bool m_setting_cache_loaded;
143 static float m_setting_chat_message_limit_per_10sec;
144 static u16 m_setting_chat_message_limit_trigger_kick;
146 u32 m_last_chat_message_sent;
147 float m_chat_message_allowance;
148 u16 m_message_rate_overhead;
150 bool m_day_night_ratio_do_override;
151 float m_day_night_ratio;
152 std::string hud_hotbar_image;
153 std::string hud_hotbar_selected_image;
155 std::string m_sky_type;
156 video::SColor m_sky_bgcolor;
157 std::vector<std::string> m_sky_params;