summaryrefslogtreecommitdiff
path: root/src/player.h
diff options
context:
space:
mode:
authorBen Deutsch <ben@bendeutsch.de>2018-04-18 20:56:01 +0200
committerSmallJoker <SmallJoker@users.noreply.github.com>2018-04-18 20:56:01 +0200
commit3eac24946418d787697077cc1806856e514ba5f4 (patch)
treeb831acb5d872cdc0f46123e92be9bb21f46d8d9f /src/player.h
parentb1e58c9c35ae3eb6167a0745086cdb0ddb1dd9d7 (diff)
downloadminetest-3eac24946418d787697077cc1806856e514ba5f4.tar.gz
minetest-3eac24946418d787697077cc1806856e514ba5f4.tar.bz2
minetest-3eac24946418d787697077cc1806856e514ba5f4.zip
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.
Diffstat (limited to 'src/player.h')
-rw-r--r--src/player.h15
1 files changed, 15 insertions, 0 deletions
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;
};