Luanti 5.15.0-dev
 
Loading...
Searching...
No Matches
remoteplayer.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2010-2016 celeron55, Perttu Ahola <celeron55@gmail.com>
4// Copyright (C) 2014-2016 nerzhul, Loic Blot <loic.blot@unix-experience.fr>
5
6#pragma once
7
8#include "constants.h" // PEER_ID_INEXISTENT
9#include "player.h"
10#include "skyparams.h"
11#include "lighting.h"
12#include "network/networkprotocol.h" // session_t
13
14class PlayerSAO;
15
22
23/*
24 Player on the server
25*/
26class RemotePlayer : public Player
27{
28 friend class PlayerDatabaseFiles;
29
30public:
31 RemotePlayer(const std::string &name, IItemDefManager *idef);
32 virtual ~RemotePlayer();
33
35 void setPlayerSAO(PlayerSAO *sao) { m_sao = sao; }
36
38
39 void setHotbarItemcount(s32 hotbar_itemcount)
40 {
41 hud_hotbar_itemcount = hotbar_itemcount;
42 }
43
45
46 void overrideDayNightRatio(bool do_override, float ratio)
47 {
49 m_day_night_ratio = ratio;
50 }
51
52 void getDayNightRatio(bool *do_override, float *ratio)
53 {
54 *do_override = m_day_night_ratio_do_override;
55 *ratio = m_day_night_ratio;
56 }
57
58 void setHotbarImage(const std::string &name) { hud_hotbar_image = name; }
59
60 const std::string &getHotbarImage() const { return hud_hotbar_image; }
61
62 void setHotbarSelectedImage(const std::string &name)
63 {
65 }
66
67 const std::string &getHotbarSelectedImage() const
68 {
70 }
71
72 void setSky(const SkyboxParams &skybox_params)
73 {
74 m_skybox_params = skybox_params;
75 }
76
77 const SkyboxParams &getSkyParams() const { return m_skybox_params; }
78
79 void setSun(const SunParams &sun_params) { m_sun_params = sun_params; }
80
81 const SunParams &getSunParams() const { return m_sun_params; }
82
83 void setMoon(const MoonParams &moon_params) { m_moon_params = moon_params; }
84
85 const MoonParams &getMoonParams() const { return m_moon_params; }
86
87 void setStars(const StarParams &star_params) { m_star_params = star_params; }
88
89 const StarParams &getStarParams() const { return m_star_params; }
90
91 void setCloudParams(const CloudParams &cloud_params)
92 {
93 m_cloud_params = cloud_params;
94 }
95
96 const CloudParams &getCloudParams() const { return m_cloud_params; }
97
98 bool checkModified() const { return m_dirty || inventory.checkModified(); }
99
100 inline void setModified(const bool x) { m_dirty = x; }
101
102 void setLocalAnimations(v2f frames[4], float frame_speed)
103 {
104 for (int i = 0; i < 4; i++)
105 local_animations[i] = frames[i];
106 local_animation_speed = frame_speed;
107 }
108
109 void getLocalAnimations(v2f *frames, float *frame_speed)
110 {
111 for (int i = 0; i < 4; i++)
112 frames[i] = local_animations[i];
113 *frame_speed = local_animation_speed;
114 }
115
116 void setLighting(const Lighting &lighting) { m_lighting = lighting; }
117
118 const Lighting& getLighting() const { return m_lighting; }
119
120 void setDirty(bool dirty) { m_dirty = true; }
121
124
126
129 session_t getPeerId() const { return m_peer_id; }
130
131 void setPeerId(session_t peer_id) { m_peer_id = peer_id; }
132
133 void onSuccessfulSave();
134
135private:
136 PlayerSAO *m_sao = nullptr;
137 bool m_dirty = false;
138
142
143 u32 m_last_chat_message_sent = std::time(0);
146
149 std::string hud_hotbar_image = "";
151
153
158
160
162};
Definition itemdef.h:146
bool checkModified() const
Definition inventory.h:311
Definition database-files.h:17
Definition player_sao.h:58
Definition player.h:140
v2f local_animations[4]
Definition player.h:190
s32 hud_hotbar_itemcount
Definition player.h:226
Inventory inventory
Definition player.h:175
float local_animation_speed
Definition player.h:191
Definition remoteplayer.h:27
const SunParams & getSunParams() const
Definition remoteplayer.h:81
std::string hud_hotbar_image
Definition remoteplayer.h:149
const Lighting & getLighting() const
Definition remoteplayer.h:118
session_t m_peer_id
Definition remoteplayer.h:161
RemotePlayer(const std::string &name, IItemDefManager *idef)
Definition remoteplayer.cpp:22
bool checkModified() const
Definition remoteplayer.h:98
void setHotbarItemcount(s32 hotbar_itemcount)
Definition remoteplayer.h:39
const CloudParams & getCloudParams() const
Definition remoteplayer.h:96
void setCloudParams(const CloudParams &cloud_params)
Definition remoteplayer.h:91
const std::string & getHotbarImage() const
Definition remoteplayer.h:60
void setModified(const bool x)
Definition remoteplayer.h:100
void setHotbarImage(const std::string &name)
Definition remoteplayer.h:58
session_t getPeerId() const
returns PEER_ID_INEXISTENT when PlayerSAO is either not yet present or about to be removed (e....
Definition remoteplayer.h:129
const MoonParams & getMoonParams() const
Definition remoteplayer.h:85
u16 m_message_rate_overhead
Definition remoteplayer.h:145
CloudParams m_cloud_params
Definition remoteplayer.h:152
void getDayNightRatio(bool *do_override, float *ratio)
Definition remoteplayer.h:52
RemotePlayerChatResult canSendChatMessage()
Definition remoteplayer.cpp:60
const StarParams & getStarParams() const
Definition remoteplayer.h:89
void setPeerId(session_t peer_id)
Definition remoteplayer.h:131
SunParams m_sun_params
Definition remoteplayer.h:155
const SkyboxParams & getSkyParams() const
Definition remoteplayer.h:77
void setLighting(const Lighting &lighting)
Definition remoteplayer.h:116
bool inventory_formspec_overridden
Definition remoteplayer.h:125
SkyboxParams m_skybox_params
Definition remoteplayer.h:154
s32 getHotbarItemcount() const
Definition remoteplayer.h:44
bool m_dirty
Definition remoteplayer.h:137
void setPlayerSAO(PlayerSAO *sao)
Definition remoteplayer.h:35
static u16 m_setting_chat_message_limit_trigger_kick
Definition remoteplayer.h:141
bool m_day_night_ratio_do_override
Definition remoteplayer.h:147
StarParams m_star_params
Definition remoteplayer.h:157
Lighting m_lighting
Definition remoteplayer.h:159
void setLocalAnimations(v2f frames[4], float frame_speed)
Definition remoteplayer.h:102
u32 m_last_chat_message_sent
Definition remoteplayer.h:143
PlayerSAO * m_sao
Definition remoteplayer.h:136
void setStars(const StarParams &star_params)
Definition remoteplayer.h:87
void setHotbarSelectedImage(const std::string &name)
Definition remoteplayer.h:62
u16 formspec_version
Definition remoteplayer.h:123
void setDirty(bool dirty)
Definition remoteplayer.h:120
void setSun(const SunParams &sun_params)
Definition remoteplayer.h:79
float m_chat_message_allowance
Definition remoteplayer.h:144
void getLocalAnimations(v2f *frames, float *frame_speed)
Definition remoteplayer.h:109
static bool m_setting_cache_loaded
Definition remoteplayer.h:139
static float m_setting_chat_message_limit_per_10sec
Definition remoteplayer.h:140
float m_day_night_ratio
Definition remoteplayer.h:148
PlayerSAO * getPlayerSAO()
Definition remoteplayer.h:34
virtual ~RemotePlayer()
Definition remoteplayer.cpp:54
void onSuccessfulSave()
Definition remoteplayer.cpp:99
void setSky(const SkyboxParams &skybox_params)
Definition remoteplayer.h:72
const std::string & getHotbarSelectedImage() const
Definition remoteplayer.h:67
void setMoon(const MoonParams &moon_params)
Definition remoteplayer.h:83
void overrideDayNightRatio(bool do_override, float ratio)
Definition remoteplayer.h:46
u16 protocol_version
Definition remoteplayer.h:122
std::string hud_hotbar_selected_image
Definition remoteplayer.h:150
MoonParams m_moon_params
Definition remoteplayer.h:156
#define PEER_ID_INEXISTENT
Definition constants.h:19
core::vector2d< f32 > v2f
Definition irr_v2d.h:11
u16 session_t
Definition networkprotocol.h:27
RemotePlayerChatResult
Definition remoteplayer.h:17
@ RPLAYER_CHATRESULT_OK
Definition remoteplayer.h:18
@ RPLAYER_CHATRESULT_KICK
Definition remoteplayer.h:20
@ RPLAYER_CHATRESULT_FLOODING
Definition remoteplayer.h:19
Definition skyparams.h:71
Describes ambient light settings for a player.
Definition lighting.h:45
Definition skyparams.h:53
Definition skyparams.h:25
Definition skyparams.h:61
Definition skyparams.h:43
constexpr v3f x
Definition test_irr_matrix4.cpp:18