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);
45 PlayerSAO *getPlayerSAO() { return m_sao; }
46 void setPlayerSAO(PlayerSAO *sao) { m_sao = sao; }
47 void setPosition(const v3f &position);
49 const RemotePlayerChatResult canSendChatMessage();
51 void setHotbarItemcount(s32 hotbar_itemcount)
53 hud_hotbar_itemcount = hotbar_itemcount;
56 s32 getHotbarItemcount() const { return hud_hotbar_itemcount; }
58 void overrideDayNightRatio(bool do_override, float ratio)
60 m_day_night_ratio_do_override = do_override;
61 m_day_night_ratio = ratio;
64 void getDayNightRatio(bool *do_override, float *ratio)
66 *do_override = m_day_night_ratio_do_override;
67 *ratio = m_day_night_ratio;
70 // Use a function, if isDead can be defined by other conditions
71 bool isDead() const { return hp == 0; }
73 void setHotbarImage(const std::string &name)
75 hud_hotbar_image = name;
78 std::string getHotbarImage() const
80 return hud_hotbar_image;
83 void setHotbarSelectedImage(const std::string &name)
85 hud_hotbar_selected_image = name;
88 const std::string &getHotbarSelectedImage() const
90 return hud_hotbar_selected_image;
94 f32 getRadPitchDep() const { return -1.0 * m_pitch * core::DEGTORAD; }
97 f32 getRadYawDep() const { return (m_yaw + 90.) * core::DEGTORAD; }
99 void setSky(const video::SColor &bgcolor, const std::string &type,
100 const std::vector<std::string> ¶ms)
102 m_sky_bgcolor = bgcolor;
104 m_sky_params = params;
107 void getSky(video::SColor *bgcolor, std::string *type,
108 std::vector<std::string> *params)
110 *bgcolor = m_sky_bgcolor;
112 *params = m_sky_params;
115 bool checkModified() const { return m_dirty || inventory.checkModified(); }
117 void setModified(const bool x)
121 inventory.setModified(x);
124 virtual void setBreath(u16 breath)
126 if (breath != m_breath)
128 Player::setBreath(breath);
131 virtual void setPitch(f32 pitch)
133 if (pitch != m_pitch)
135 Player::setPitch(pitch);
138 virtual void setYaw(f32 yaw)
145 void setLocalAnimations(v2s32 frames[4], float frame_speed)
147 for (int i = 0; i < 4; i++)
148 local_animations[i] = frames[i];
149 local_animation_speed = frame_speed;
152 void getLocalAnimations(v2s32 *frames, float *frame_speed)
154 for (int i = 0; i < 4; i++)
155 frames[i] = local_animations[i];
156 *frame_speed = local_animation_speed;
159 u16 protocol_version;
162 serialize() writes a bunch of text that can contain
163 any characters except a '\0', and such an ending that
164 deSerialize stops reading exactly at the right point.
166 void serialize(std::ostream &os);
171 static bool m_setting_cache_loaded;
172 static float m_setting_chat_message_limit_per_10sec;
173 static u16 m_setting_chat_message_limit_trigger_kick;
175 u32 m_last_chat_message_sent;
176 float m_chat_message_allowance;
177 u16 m_message_rate_overhead;
179 bool m_day_night_ratio_do_override;
180 float m_day_night_ratio;
181 std::string hud_hotbar_image;
182 std::string hud_hotbar_selected_image;
184 std::string m_sky_type;
185 video::SColor m_sky_bgcolor;
186 std::vector<std::string> m_sky_params;