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
30 RPLAYER_CHATRESULT_OK,
31 RPLAYER_CHATRESULT_FLOODING,
32 RPLAYER_CHATRESULT_KICK,
38 class RemotePlayer : public Player
40 friend class PlayerDatabaseFiles;
42 RemotePlayer(const char *name, IItemDefManager *idef);
43 virtual ~RemotePlayer() {}
45 void deSerialize(std::istream &is, const std::string &playername, PlayerSAO *sao);
47 PlayerSAO *getPlayerSAO() { return m_sao; }
48 void setPlayerSAO(PlayerSAO *sao) { m_sao = sao; }
50 const RemotePlayerChatResult canSendChatMessage();
52 void setHotbarItemcount(s32 hotbar_itemcount)
54 hud_hotbar_itemcount = hotbar_itemcount;
57 s32 getHotbarItemcount() const { return hud_hotbar_itemcount; }
59 void overrideDayNightRatio(bool do_override, float ratio)
61 m_day_night_ratio_do_override = do_override;
62 m_day_night_ratio = ratio;
65 void getDayNightRatio(bool *do_override, float *ratio)
67 *do_override = m_day_night_ratio_do_override;
68 *ratio = m_day_night_ratio;
71 void setHotbarImage(const std::string &name) { hud_hotbar_image = name; }
73 std::string getHotbarImage() const { return hud_hotbar_image; }
75 void setHotbarSelectedImage(const std::string &name)
77 hud_hotbar_selected_image = name;
80 const std::string &getHotbarSelectedImage() const
82 return hud_hotbar_selected_image;
85 void setSky(const video::SColor &bgcolor, const std::string &type,
86 const std::vector<std::string> ¶ms)
88 m_sky_bgcolor = bgcolor;
90 m_sky_params = params;
93 void getSky(video::SColor *bgcolor, std::string *type,
94 std::vector<std::string> *params)
96 *bgcolor = m_sky_bgcolor;
98 *params = m_sky_params;
101 bool checkModified() const { return m_dirty || inventory.checkModified(); }
103 void setModified(const bool x)
107 inventory.setModified(x);
110 void setLocalAnimations(v2s32 frames[4], float frame_speed)
112 for (int i = 0; i < 4; i++)
113 local_animations[i] = frames[i];
114 local_animation_speed = frame_speed;
117 void getLocalAnimations(v2s32 *frames, float *frame_speed)
119 for (int i = 0; i < 4; i++)
120 frames[i] = local_animations[i];
121 *frame_speed = local_animation_speed;
124 void setDirty(bool dirty) { m_dirty = true; }
126 u16 protocol_version;
130 serialize() writes a bunch of text that can contain
131 any characters except a '\0', and such an ending that
132 deSerialize stops reading exactly at the right point.
134 void serialize(std::ostream &os);
135 void serializeExtraAttributes(std::string &output);
140 static bool m_setting_cache_loaded;
141 static float m_setting_chat_message_limit_per_10sec;
142 static u16 m_setting_chat_message_limit_trigger_kick;
144 u32 m_last_chat_message_sent;
145 float m_chat_message_allowance;
146 u16 m_message_rate_overhead;
148 bool m_day_night_ratio_do_override;
149 float m_day_night_ratio;
150 std::string hud_hotbar_image;
151 std::string hud_hotbar_selected_image;
153 std::string m_sky_type;
154 video::SColor m_sky_bgcolor;
155 std::vector<std::string> m_sky_params;