Minetest 5.9.0-dev
 
Loading...
Searching...
No Matches
remoteplayer.h
Go to the documentation of this file.
1/*
2Minetest
3Copyright (C) 2010-2016 celeron55, Perttu Ahola <celeron55@gmail.com>
4Copyright (C) 2014-2016 nerzhul, Loic Blot <loic.blot@unix-experience.fr>
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU Lesser General Public License as published by
8the Free Software Foundation; either version 2.1 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU Lesser General Public License for more details.
15
16You should have received a copy of the GNU Lesser General Public License along
17with this program; if not, write to the Free Software Foundation, Inc.,
1851 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19*/
20
21#pragma once
22
23#include "player.h"
24#include "skyparams.h"
25#include "lighting.h"
26
27class PlayerSAO;
28
30{
34};
35
36/*
37 Player on the server
38*/
39class RemotePlayer : public Player
40{
41 friend class PlayerDatabaseFiles;
42
43public:
44 RemotePlayer(const char *name, IItemDefManager *idef);
45 virtual ~RemotePlayer();
46
48 void setPlayerSAO(PlayerSAO *sao) { m_sao = sao; }
49
51
52 void setHotbarItemcount(s32 hotbar_itemcount)
53 {
54 hud_hotbar_itemcount = hotbar_itemcount;
55 }
56
58
59 void overrideDayNightRatio(bool do_override, float ratio)
60 {
62 m_day_night_ratio = ratio;
63 }
64
65 void getDayNightRatio(bool *do_override, float *ratio)
66 {
67 *do_override = m_day_night_ratio_do_override;
68 *ratio = m_day_night_ratio;
69 }
70
71 void setHotbarImage(const std::string &name) { hud_hotbar_image = name; }
72
73 const std::string &getHotbarImage() const { return hud_hotbar_image; }
74
75 void setHotbarSelectedImage(const std::string &name)
76 {
78 }
79
80 const std::string &getHotbarSelectedImage() const
81 {
83 }
84
85 void setSky(const SkyboxParams &skybox_params)
86 {
87 m_skybox_params = skybox_params;
88 }
89
90 const SkyboxParams &getSkyParams() const { return m_skybox_params; }
91
92 void setSun(const SunParams &sun_params) { m_sun_params = sun_params; }
93
94 const SunParams &getSunParams() const { return m_sun_params; }
95
96 void setMoon(const MoonParams &moon_params) { m_moon_params = moon_params; }
97
98 const MoonParams &getMoonParams() const { return m_moon_params; }
99
100 void setStars(const StarParams &star_params) { m_star_params = star_params; }
101
102 const StarParams &getStarParams() const { return m_star_params; }
103
104 void setCloudParams(const CloudParams &cloud_params)
105 {
106 m_cloud_params = cloud_params;
107 }
108
109 const CloudParams &getCloudParams() const { return m_cloud_params; }
110
111 bool checkModified() const { return m_dirty || inventory.checkModified(); }
112
113 inline void setModified(const bool x) { m_dirty = x; }
114
115 void setLocalAnimations(v2s32 frames[4], float frame_speed)
116 {
117 for (int i = 0; i < 4; i++)
118 local_animations[i] = frames[i];
119 local_animation_speed = frame_speed;
120 }
121
122 void getLocalAnimations(v2s32 *frames, float *frame_speed)
123 {
124 for (int i = 0; i < 4; i++)
125 frames[i] = local_animations[i];
126 *frame_speed = local_animation_speed;
127 }
128
129 void setLighting(const Lighting &lighting) { m_lighting = lighting; }
130
131 const Lighting& getLighting() const { return m_lighting; }
132
133 void setDirty(bool dirty) { m_dirty = true; }
134
137
139 session_t getPeerId() const { return m_peer_id; }
140
141 void setPeerId(session_t peer_id) { m_peer_id = peer_id; }
142
143 void onSuccessfulSave();
144
145private:
146 PlayerSAO *m_sao = nullptr;
147 bool m_dirty = false;
148
152
153 u32 m_last_chat_message_sent = std::time(0);
156
159 std::string hud_hotbar_image = "";
161
163
168
170
172};
Definition: itemdef.h:143
bool checkModified() const
Definition: inventory.h:363
Definition: database-files.h:32
Definition: player_sao.h:71
Definition: player.h:158
s32 hud_hotbar_itemcount
Definition: player.h:248
Inventory inventory
Definition: player.h:197
v2s32 local_animations[4]
Definition: player.h:212
float local_animation_speed
Definition: player.h:213
Definition: remoteplayer.h:40
const SunParams & getSunParams() const
Definition: remoteplayer.h:94
std::string hud_hotbar_image
Definition: remoteplayer.h:159
const Lighting & getLighting() const
Definition: remoteplayer.h:131
session_t m_peer_id
Definition: remoteplayer.h:171
bool checkModified() const
Definition: remoteplayer.h:111
void setHotbarItemcount(s32 hotbar_itemcount)
Definition: remoteplayer.h:52
const CloudParams & getCloudParams() const
Definition: remoteplayer.h:109
void setCloudParams(const CloudParams &cloud_params)
Definition: remoteplayer.h:104
const std::string & getHotbarImage() const
Definition: remoteplayer.h:73
void setModified(const bool x)
Definition: remoteplayer.h:113
void setLocalAnimations(v2s32 frames[4], float frame_speed)
Definition: remoteplayer.h:115
void setHotbarImage(const std::string &name)
Definition: remoteplayer.h:71
session_t getPeerId() const
returns PEER_ID_INEXISTENT when PlayerSAO is not ready
Definition: remoteplayer.h:139
const MoonParams & getMoonParams() const
Definition: remoteplayer.h:98
u16 m_message_rate_overhead
Definition: remoteplayer.h:155
CloudParams m_cloud_params
Definition: remoteplayer.h:162
void getDayNightRatio(bool *do_override, float *ratio)
Definition: remoteplayer.h:65
RemotePlayerChatResult canSendChatMessage()
Definition: remoteplayer.cpp:78
const StarParams & getStarParams() const
Definition: remoteplayer.h:102
void setPeerId(session_t peer_id)
Definition: remoteplayer.h:141
SunParams m_sun_params
Definition: remoteplayer.h:165
const SkyboxParams & getSkyParams() const
Definition: remoteplayer.h:90
void setLighting(const Lighting &lighting)
Definition: remoteplayer.h:129
SkyboxParams m_skybox_params
Definition: remoteplayer.h:164
s32 getHotbarItemcount() const
Definition: remoteplayer.h:57
bool m_dirty
Definition: remoteplayer.h:147
void setPlayerSAO(PlayerSAO *sao)
Definition: remoteplayer.h:48
static u16 m_setting_chat_message_limit_trigger_kick
Definition: remoteplayer.h:151
bool m_day_night_ratio_do_override
Definition: remoteplayer.h:157
StarParams m_star_params
Definition: remoteplayer.h:167
Lighting m_lighting
Definition: remoteplayer.h:169
u32 m_last_chat_message_sent
Definition: remoteplayer.h:153
PlayerSAO * m_sao
Definition: remoteplayer.h:146
void setStars(const StarParams &star_params)
Definition: remoteplayer.h:100
void setHotbarSelectedImage(const std::string &name)
Definition: remoteplayer.h:75
u16 formspec_version
Definition: remoteplayer.h:136
void setDirty(bool dirty)
Definition: remoteplayer.h:133
void setSun(const SunParams &sun_params)
Definition: remoteplayer.h:92
float m_chat_message_allowance
Definition: remoteplayer.h:154
static bool m_setting_cache_loaded
Definition: remoteplayer.h:149
static float m_setting_chat_message_limit_per_10sec
Definition: remoteplayer.h:150
float m_day_night_ratio
Definition: remoteplayer.h:158
PlayerSAO * getPlayerSAO()
Definition: remoteplayer.h:47
virtual ~RemotePlayer()
Definition: remoteplayer.cpp:72
void onSuccessfulSave()
Definition: remoteplayer.cpp:117
void setSky(const SkyboxParams &skybox_params)
Definition: remoteplayer.h:85
void getLocalAnimations(v2s32 *frames, float *frame_speed)
Definition: remoteplayer.h:122
const std::string & getHotbarSelectedImage() const
Definition: remoteplayer.h:80
void setMoon(const MoonParams &moon_params)
Definition: remoteplayer.h:96
void overrideDayNightRatio(bool do_override, float ratio)
Definition: remoteplayer.h:59
u16 protocol_version
Definition: remoteplayer.h:135
std::string hud_hotbar_selected_image
Definition: remoteplayer.h:160
MoonParams m_moon_params
Definition: remoteplayer.h:166
#define PEER_ID_INEXISTENT
Definition: constants.h:34
core::vector2d< s32 > v2s32
Definition: irr_v2d.h:28
u16 session_t
Definition: networkprotocol.h:251
RemotePlayerChatResult
Definition: remoteplayer.h:30
@ RPLAYER_CHATRESULT_OK
Definition: remoteplayer.h:31
@ RPLAYER_CHATRESULT_KICK
Definition: remoteplayer.h:33
@ RPLAYER_CHATRESULT_FLOODING
Definition: remoteplayer.h:32
Definition: skyparams.h:80
Describes ambient light settings for a player.
Definition: lighting.h:52
Definition: skyparams.h:63
Definition: skyparams.h:35
Definition: skyparams.h:71
Definition: skyparams.h:53