1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-27 17:28:41 +00:00

Player/LocalPlayer/RemotePlayer inheritance cleanup (part 1 on X)

* LocalPlayer take ownership of maxHudId as it's the only caller
* RemotePlayer take ownership of day night ratio as it's the only user
* Pass getPlayerControl as const reference to prevent object copy on each call (perf improvement in ObjectRef::l_get_player_control call)
* getPlayerSAO is now only RemotePlayer call
* get/setHotbarItemCount is now RemotePlayer owned
* Server: Use RemotePlayer instead of Player object on concerned call to properly fix the object type
* PlayerSAO now uses RemotePlayer instead of Player because it's only server side
* ObjectRef::getplayer also returns RemotePlayer as it's linked with PlayerSAO
This commit is contained in:
Loic Blot 2016-10-08 10:38:04 +02:00 committed by Ner'zhul
parent 0264e38bff
commit 8bcd10b872
12 changed files with 103 additions and 109 deletions

View file

@ -233,16 +233,6 @@ public:
return size;
}
void setHotbarItemcount(s32 hotbar_itemcount)
{
hud_hotbar_itemcount = hotbar_itemcount;
}
s32 getHotbarItemcount()
{
return hud_hotbar_itemcount;
}
void setHotbarImage(const std::string &name)
{
hud_hotbar_image = name;
@ -278,18 +268,6 @@ public:
*params = m_sky_params;
}
void overrideDayNightRatio(bool do_override, float ratio)
{
m_day_night_ratio_do_override = do_override;
m_day_night_ratio = ratio;
}
void getDayNightRatio(bool *do_override, float *ratio)
{
*do_override = m_day_night_ratio_do_override;
*ratio = m_day_night_ratio;
}
void setLocalAnimations(v2s32 frames[4], float frame_speed)
{
for (int i = 0; i < 4; i++)
@ -309,11 +287,6 @@ public:
return false;
}
virtual PlayerSAO *getPlayerSAO()
{
return NULL;
}
virtual void setPlayerSAO(PlayerSAO *sao)
{
FATAL_ERROR("FIXME");
@ -335,7 +308,7 @@ public:
void setModified(const bool x)
{
m_dirty = x;
if (x == false)
if (!x)
inventory.setModified(x);
}
@ -391,10 +364,7 @@ public:
std::string inventory_formspec;
PlayerControl control;
PlayerControl getPlayerControl()
{
return control;
}
const PlayerControl& getPlayerControl() { return control; }
u32 keyPressed;
@ -403,9 +373,6 @@ public:
u32 addHud(HudElement* hud);
HudElement* removeHud(u32 id);
void clearHud();
u32 maxHudId() {
return hud.size();
}
u32 hud_flags;
s32 hud_hotbar_itemcount;
@ -429,9 +396,6 @@ protected:
std::string m_sky_type;
video::SColor m_sky_bgcolor;
std::vector<std::string> m_sky_params;
bool m_day_night_ratio_do_override;
float m_day_night_ratio;
private:
// Protect some critical areas
// hud for example can be modified by EmergeThread
@ -463,6 +427,25 @@ public:
const RemotePlayerChatResult canSendChatMessage();
void setHotbarItemcount(s32 hotbar_itemcount)
{
hud_hotbar_itemcount = hotbar_itemcount;
}
s32 getHotbarItemcount() const { return hud_hotbar_itemcount; }
void overrideDayNightRatio(bool do_override, float ratio)
{
m_day_night_ratio_do_override = do_override;
m_day_night_ratio = ratio;
}
void getDayNightRatio(bool *do_override, float *ratio)
{
*do_override = m_day_night_ratio_do_override;
*ratio = m_day_night_ratio;
}
private:
PlayerSAO *m_sao;
@ -473,6 +456,9 @@ private:
u32 m_last_chat_message_sent;
float m_chat_message_allowance;
u16 m_message_rate_overhead;
bool m_day_night_ratio_do_override;
float m_day_night_ratio;
};
#endif