mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-18 02:45:21 +02:00
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.
This commit is contained in:
15
src/player.h
15
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;
|
||||
};
|
||||
|
Reference in New Issue
Block a user