From 3eac24946418d787697077cc1806856e514ba5f4 Mon Sep 17 00:00:00 2001 From: Ben Deutsch Date: Wed, 18 Apr 2018 20:56:01 +0200 Subject: PlayerSettings struct for player movement code (#7243) Instead of calling g_settings->getBool("flag") multiple times during each movement step, the current settings are cached in a new player object member. Updated via registered callbacks. --- src/player.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/player.h') diff --git a/src/player.h b/src/player.h index 2d4bfd839..ca16111e1 100644 --- a/src/player.h +++ b/src/player.h @@ -84,6 +84,18 @@ struct PlayerControl float forw_move_joystick_axis = 0.0f; }; +struct PlayerSettings +{ + bool free_move = false; + bool fast_move = false; + bool continuous_forward = false; + bool always_fly_fast = false; + bool aux1_descends = false; + bool noclip = false; + + void readGlobalSettings(); +}; + class Map; struct CollisionInfo; struct HudElement; @@ -152,6 +164,8 @@ public: PlayerControl control; const PlayerControl& getPlayerControl() { return control; } + PlayerSettings &getPlayerSettings() { return m_player_settings; } + static void settingsChangedCallback(const std::string &name, void *data); u32 keyPressed = 0; @@ -172,4 +186,5 @@ private: // hud for example can be modified by EmergeThread // and ServerThread std::mutex m_mutex; + PlayerSettings m_player_settings; }; -- cgit v1.2.3