diff options
author | Loic Blot <loic.blot@unix-experience.fr> | 2016-10-08 10:38:04 +0200 |
---|---|---|
committer | Ner'zhul <nerzhul@users.noreply.github.com> | 2016-10-08 11:36:28 +0200 |
commit | 8bcd10b872bc88c6f474913d6efb8d53c50c5ae1 (patch) | |
tree | 39a8af0048ed642eddc43c74ab9f736558663e9d /src/player.h | |
parent | 0264e38bff12a3c6b81231ac1f6cd281179df744 (diff) | |
download | minetest-8bcd10b872bc88c6f474913d6efb8d53c50c5ae1.tar.gz minetest-8bcd10b872bc88c6f474913d6efb8d53c50c5ae1.tar.bz2 minetest-8bcd10b872bc88c6f474913d6efb8d53c50c5ae1.zip |
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
Diffstat (limited to 'src/player.h')
-rw-r--r-- | src/player.h | 62 |
1 files changed, 24 insertions, 38 deletions
diff --git a/src/player.h b/src/player.h index f38effa9d..fbd88fc71 100644 --- a/src/player.h +++ b/src/player.h @@ -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 |