nlist: make selected list accessible globally
[waspsaliva.git] / src / remoteplayer.h
blobe4209c54f26d07b890d1061b5b0ad0665c9ad4c3
1 /*
2 Minetest
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 #pragma once
23 #include "player.h"
24 #include "cloudparams.h"
25 #include "skyparams.h"
27 class PlayerSAO;
29 enum RemotePlayerChatResult
31 RPLAYER_CHATRESULT_OK,
32 RPLAYER_CHATRESULT_FLOODING,
33 RPLAYER_CHATRESULT_KICK,
37 Player on the server
39 class RemotePlayer : public Player
41 friend class PlayerDatabaseFiles;
43 public:
44 RemotePlayer(const char *name, IItemDefManager *idef);
45 virtual ~RemotePlayer() = default;
47 void deSerialize(std::istream &is, const std::string &playername, PlayerSAO *sao);
49 PlayerSAO *getPlayerSAO() { return m_sao; }
50 void setPlayerSAO(PlayerSAO *sao) { m_sao = sao; }
52 const RemotePlayerChatResult canSendChatMessage();
54 void setHotbarItemcount(s32 hotbar_itemcount)
56 hud_hotbar_itemcount = hotbar_itemcount;
59 s32 getHotbarItemcount() const { return hud_hotbar_itemcount; }
61 void overrideDayNightRatio(bool do_override, float ratio)
63 m_day_night_ratio_do_override = do_override;
64 m_day_night_ratio = ratio;
67 void getDayNightRatio(bool *do_override, float *ratio)
69 *do_override = m_day_night_ratio_do_override;
70 *ratio = m_day_night_ratio;
73 void setHotbarImage(const std::string &name) { hud_hotbar_image = name; }
75 const std::string &getHotbarImage() const { return hud_hotbar_image; }
77 void setHotbarSelectedImage(const std::string &name)
79 hud_hotbar_selected_image = name;
82 const std::string &getHotbarSelectedImage() const
84 return hud_hotbar_selected_image;
87 void setSky(const SkyboxParams &skybox_params)
89 m_skybox_params = skybox_params;
92 const SkyboxParams &getSkyParams() const { return m_skybox_params; }
94 void setSun(const SunParams &sun_params) { m_sun_params = sun_params; }
96 const SunParams &getSunParams() const { return m_sun_params; }
98 void setMoon(const MoonParams &moon_params) { m_moon_params = moon_params; }
100 const MoonParams &getMoonParams() const { return m_moon_params; }
102 void setStars(const StarParams &star_params) { m_star_params = star_params; }
104 const StarParams &getStarParams() const { return m_star_params; }
106 void setCloudParams(const CloudParams &cloud_params)
108 m_cloud_params = cloud_params;
111 const CloudParams &getCloudParams() const { return m_cloud_params; }
113 bool checkModified() const { return m_dirty || inventory.checkModified(); }
115 inline void setModified(const bool x) { m_dirty = x; }
117 void setLocalAnimations(v2s32 frames[4], float frame_speed)
119 for (int i = 0; i < 4; i++)
120 local_animations[i] = frames[i];
121 local_animation_speed = frame_speed;
124 void getLocalAnimations(v2s32 *frames, float *frame_speed)
126 for (int i = 0; i < 4; i++)
127 frames[i] = local_animations[i];
128 *frame_speed = local_animation_speed;
131 void setDirty(bool dirty) { m_dirty = true; }
133 u16 protocol_version = 0;
135 // v1 for clients older than 5.1.0-dev
136 u16 formspec_version = 1;
138 session_t getPeerId() const { return m_peer_id; }
140 void setPeerId(session_t peer_id) { m_peer_id = peer_id; }
142 void onSuccessfulSave();
144 private:
146 serialize() writes a bunch of text that can contain
147 any characters except a '\0', and such an ending that
148 deSerialize stops reading exactly at the right point.
150 void serialize(std::ostream &os);
151 void serializeExtraAttributes(std::string &output);
153 PlayerSAO *m_sao = nullptr;
154 bool m_dirty = false;
156 static bool m_setting_cache_loaded;
157 static float m_setting_chat_message_limit_per_10sec;
158 static u16 m_setting_chat_message_limit_trigger_kick;
160 u32 m_last_chat_message_sent = std::time(0);
161 float m_chat_message_allowance = 5.0f;
162 u16 m_message_rate_overhead = 0;
164 bool m_day_night_ratio_do_override = false;
165 float m_day_night_ratio;
166 std::string hud_hotbar_image = "";
167 std::string hud_hotbar_selected_image = "";
169 CloudParams m_cloud_params;
171 SkyboxParams m_skybox_params;
172 SunParams m_sun_params;
173 MoonParams m_moon_params;
174 StarParams m_star_params;
176 session_t m_peer_id = PEER_ID_INEXISTENT;