mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-27 17:28:41 +00: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:
parent
b1e58c9c35
commit
3eac249464
3 changed files with 63 additions and 15 deletions
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;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue