Luanti 5.10.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 "player.h"
9#include "skyparams.h"
10#include "lighting.h"
11#include "network/networkprotocol.h" // session_t
12
13class PlayerSAO;
14
21
22/*
23 Player on the server
24*/
25class RemotePlayer : public Player
26{
27 friend class PlayerDatabaseFiles;
28
29public:
30 RemotePlayer(const std::string &name, IItemDefManager *idef);
31 virtual ~RemotePlayer();
32
34 void setPlayerSAO(PlayerSAO *sao) { m_sao = sao; }
35
37
38 void setHotbarItemcount(s32 hotbar_itemcount)
39 {
40 hud_hotbar_itemcount = hotbar_itemcount;
41 }
42
44
45 void overrideDayNightRatio(bool do_override, float ratio)
46 {
48 m_day_night_ratio = ratio;
49 }
50
51 void getDayNightRatio(bool *do_override, float *ratio)
52 {
53 *do_override = m_day_night_ratio_do_override;
54 *ratio = m_day_night_ratio;
55 }
56
57 void setHotbarImage(const std::string &name) { hud_hotbar_image = name; }
58
59 const std::string &getHotbarImage() const { return hud_hotbar_image; }
60
61 void setHotbarSelectedImage(const std::string &name)
62 {
64 }
65
66 const std::string &getHotbarSelectedImage() const
67 {
69 }
70
71 void setSky(const SkyboxParams &skybox_params)
72 {
73 m_skybox_params = skybox_params;
74 }
75
76 const SkyboxParams &getSkyParams() const { return m_skybox_params; }
77
78 void setSun(const SunParams &sun_params) { m_sun_params = sun_params; }
79
80 const SunParams &getSunParams() const { return m_sun_params; }
81
82 void setMoon(const MoonParams &moon_params) { m_moon_params = moon_params; }
83
84 const MoonParams &getMoonParams() const { return m_moon_params; }
85
86 void setStars(const StarParams &star_params) { m_star_params = star_params; }
87
88 const StarParams &getStarParams() const { return m_star_params; }
89
90 void setCloudParams(const CloudParams &cloud_params)
91 {
92 m_cloud_params = cloud_params;
93 }
94
95 const CloudParams &getCloudParams() const { return m_cloud_params; }
96
97 bool checkModified() const { return m_dirty || inventory.checkModified(); }
98
99 inline void setModified(const bool x) { m_dirty = x; }
100
101 void setLocalAnimations(v2f frames[4], float frame_speed)
102 {
103 for (int i = 0; i < 4; i++)
104 local_animations[i] = frames[i];
105 local_animation_speed = frame_speed;
106 }
107
108 void getLocalAnimations(v2f *frames, float *frame_speed)
109 {
110 for (int i = 0; i < 4; i++)
111 frames[i] = local_animations[i];
112 *frame_speed = local_animation_speed;
113 }
114
115 void setLighting(const Lighting &lighting) { m_lighting = lighting; }
116
117 const Lighting& getLighting() const { return m_lighting; }
118
119 void setDirty(bool dirty) { m_dirty = true; }
120
123
125 session_t getPeerId() const { return m_peer_id; }
126
127 void setPeerId(session_t peer_id) { m_peer_id = peer_id; }
128
129 void onSuccessfulSave();
130
131private:
132 PlayerSAO *m_sao = nullptr;
133 bool m_dirty = false;
134
138
139 u32 m_last_chat_message_sent = std::time(0);
142
145 std::string hud_hotbar_image = "";
147
149
154
156
158};
Definition itemdef.h:129
bool checkModified() const
Definition inventory.h:348
Definition database-files.h:17
Definition player_sao.h:56
Definition player.h:135
v2f local_animations[4]
Definition player.h:189
s32 hud_hotbar_itemcount
Definition player.h:225
Inventory inventory
Definition player.h:174
float local_animation_speed
Definition player.h:190
Definition remoteplayer.h:26
const SunParams & getSunParams() const
Definition remoteplayer.h:80
std::string hud_hotbar_image
Definition remoteplayer.h:145
const Lighting & getLighting() const
Definition remoteplayer.h:117
session_t m_peer_id
Definition remoteplayer.h:157
RemotePlayer(const std::string &name, IItemDefManager *idef)
Definition remoteplayer.cpp:25
bool checkModified() const
Definition remoteplayer.h:97
void setHotbarItemcount(s32 hotbar_itemcount)
Definition remoteplayer.h:38
const CloudParams & getCloudParams() const
Definition remoteplayer.h:95
void setCloudParams(const CloudParams &cloud_params)
Definition remoteplayer.h:90
const std::string & getHotbarImage() const
Definition remoteplayer.h:59
void setModified(const bool x)
Definition remoteplayer.h:99
void setHotbarImage(const std::string &name)
Definition remoteplayer.h:57
session_t getPeerId() const
returns PEER_ID_INEXISTENT when PlayerSAO is not ready
Definition remoteplayer.h:125
const MoonParams & getMoonParams() const
Definition remoteplayer.h:84
u16 m_message_rate_overhead
Definition remoteplayer.h:141
CloudParams m_cloud_params
Definition remoteplayer.h:148
void getDayNightRatio(bool *do_override, float *ratio)
Definition remoteplayer.h:51
RemotePlayerChatResult canSendChatMessage()
Definition remoteplayer.cpp:63
const StarParams & getStarParams() const
Definition remoteplayer.h:88
void setPeerId(session_t peer_id)
Definition remoteplayer.h:127
SunParams m_sun_params
Definition remoteplayer.h:151
const SkyboxParams & getSkyParams() const
Definition remoteplayer.h:76
void setLighting(const Lighting &lighting)
Definition remoteplayer.h:115
SkyboxParams m_skybox_params
Definition remoteplayer.h:150
s32 getHotbarItemcount() const
Definition remoteplayer.h:43
bool m_dirty
Definition remoteplayer.h:133
void setPlayerSAO(PlayerSAO *sao)
Definition remoteplayer.h:34
static u16 m_setting_chat_message_limit_trigger_kick
Definition remoteplayer.h:137
bool m_day_night_ratio_do_override
Definition remoteplayer.h:143
StarParams m_star_params
Definition remoteplayer.h:153
Lighting m_lighting
Definition remoteplayer.h:155
void setLocalAnimations(v2f frames[4], float frame_speed)
Definition remoteplayer.h:101
u32 m_last_chat_message_sent
Definition remoteplayer.h:139
PlayerSAO * m_sao
Definition remoteplayer.h:132
void setStars(const StarParams &star_params)
Definition remoteplayer.h:86
void setHotbarSelectedImage(const std::string &name)
Definition remoteplayer.h:61
u16 formspec_version
Definition remoteplayer.h:122
void setDirty(bool dirty)
Definition remoteplayer.h:119
void setSun(const SunParams &sun_params)
Definition remoteplayer.h:78
float m_chat_message_allowance
Definition remoteplayer.h:140
void getLocalAnimations(v2f *frames, float *frame_speed)
Definition remoteplayer.h:108
static bool m_setting_cache_loaded
Definition remoteplayer.h:135
static float m_setting_chat_message_limit_per_10sec
Definition remoteplayer.h:136
float m_day_night_ratio
Definition remoteplayer.h:144
PlayerSAO * getPlayerSAO()
Definition remoteplayer.h:33
virtual ~RemotePlayer()
Definition remoteplayer.cpp:57
void onSuccessfulSave()
Definition remoteplayer.cpp:102
void setSky(const SkyboxParams &skybox_params)
Definition remoteplayer.h:71
const std::string & getHotbarSelectedImage() const
Definition remoteplayer.h:66
void setMoon(const MoonParams &moon_params)
Definition remoteplayer.h:82
void overrideDayNightRatio(bool do_override, float ratio)
Definition remoteplayer.h:45
u16 protocol_version
Definition remoteplayer.h:121
std::string hud_hotbar_selected_image
Definition remoteplayer.h:146
MoonParams m_moon_params
Definition remoteplayer.h:152
#define PEER_ID_INEXISTENT
Definition constants.h:19
core::vector2d< f32 > v2f
Definition irr_v2d.h:11
u16 session_t
Definition networkprotocol.h:22
RemotePlayerChatResult
Definition remoteplayer.h:16
@ RPLAYER_CHATRESULT_OK
Definition remoteplayer.h:17
@ RPLAYER_CHATRESULT_KICK
Definition remoteplayer.h:19
@ RPLAYER_CHATRESULT_FLOODING
Definition remoteplayer.h:18
Definition skyparams.h:65
Describes ambient light settings for a player.
Definition lighting.h:39
Definition skyparams.h:48
Definition skyparams.h:20
Definition skyparams.h:56
Definition skyparams.h:38