return;
}
+ PlayerSettings &player_settings = getPlayerSettings();
+
// Skip collision detection if noclip mode is used
bool fly_allowed = m_client->checkLocalPrivilege("fly");
- bool noclip = m_client->checkLocalPrivilege("noclip") &&
- g_settings->getBool("noclip");
- bool free_move = g_settings->getBool("free_move") && fly_allowed;
+ bool noclip = m_client->checkLocalPrivilege("noclip") && player_settings.noclip;
+ bool free_move = player_settings.free_move && fly_allowed;
if (noclip && free_move) {
position += m_speed * dtime;
return;
}
+ PlayerSettings &player_settings = getPlayerSettings();
+
v3f move_direction = v3f(0,0,1);
move_direction.rotateXZBy(getYaw());
bool fly_allowed = m_client->checkLocalPrivilege("fly");
bool fast_allowed = m_client->checkLocalPrivilege("fast");
- bool free_move = fly_allowed && g_settings->getBool("free_move");
- bool fast_move = fast_allowed && g_settings->getBool("fast_move");
+ bool free_move = fly_allowed && player_settings.free_move;
+ bool fast_move = fast_allowed && player_settings.fast_move;
// When aux1_descends is enabled the fast key is used to go down, so fast isn't possible
- bool fast_climb = fast_move && control.aux1 && !g_settings->getBool("aux1_descends");
- bool continuous_forward = g_settings->getBool("continuous_forward");
- bool always_fly_fast = g_settings->getBool("always_fly_fast");
+ bool fast_climb = fast_move && control.aux1 && !player_settings.aux1_descends;
+ bool continuous_forward = player_settings.continuous_forward;
+ bool always_fly_fast = player_settings.always_fly_fast;
// Whether superspeed mode is used or not
bool superspeed = false;
superspeed = true;
// Old descend control
- if(g_settings->getBool("aux1_descends"))
+ if (player_settings.aux1_descends)
{
// If free movement and fast movement, always move fast
if(free_move && fast_move)
if(control.jump)
{
if (free_move) {
- if (g_settings->getBool("aux1_descends") || always_fly_fast) {
+ if (player_settings.aux1_descends || always_fly_fast) {
if (fast_move)
speedV.Y = movement_speed_fast;
else
return;
}
+ PlayerSettings &player_settings = getPlayerSettings();
+
// Skip collision detection if noclip mode is used
bool fly_allowed = m_client->checkLocalPrivilege("fly");
- bool noclip = m_client->checkLocalPrivilege("noclip") &&
- g_settings->getBool("noclip");
- bool free_move = noclip && fly_allowed && g_settings->getBool("free_move");
+ bool noclip = m_client->checkLocalPrivilege("noclip") && player_settings.noclip;
+ bool free_move = noclip && fly_allowed && player_settings.free_move;
if (free_move) {
position += m_speed * dtime;
setPosition(position);
fall off from it
*/
if (control.sneak && m_sneak_node_exists &&
- !(fly_allowed && g_settings->getBool("free_move")) && !in_liquid &&
+ !(fly_allowed && player_settings.free_move) && !in_liquid &&
physics_override_sneak) {
f32 maxd = 0.5 * BS + sneak_max;
v3f lwn_f = intToFloat(m_sneak_node, BS);
Report collisions
*/
// Dont report if flying
- if (collision_info && !(g_settings->getBool("free_move") && fly_allowed)) {
+ if (collision_info && !(player_settings.free_move && fly_allowed)) {
for (const auto &info : result.collisions) {
collision_info->push_back(info);
}
HUD_FLAG_MINIMAP_RADAR_VISIBLE;
hud_hotbar_itemcount = HUD_HOTBAR_ITEMCOUNT_DEFAULT;
+
+ m_player_settings.readGlobalSettings();
+ g_settings->registerChangedCallback("free_move", &Player::settingsChangedCallback,
+ &m_player_settings);
+ g_settings->registerChangedCallback("fast_move", &Player::settingsChangedCallback,
+ &m_player_settings);
+ g_settings->registerChangedCallback("continuous_forward",
+ &Player::settingsChangedCallback, &m_player_settings);
+ g_settings->registerChangedCallback("always_fly_fast",
+ &Player::settingsChangedCallback, &m_player_settings);
+ g_settings->registerChangedCallback("aux1_descends",
+ &Player::settingsChangedCallback, &m_player_settings);
+ g_settings->registerChangedCallback(
+ "noclip", &Player::settingsChangedCallback, &m_player_settings);
}
Player::~Player()
hud.pop_back();
}
}
+
+void PlayerSettings::readGlobalSettings()
+{
+ free_move = g_settings->getBool("free_move");
+ fast_move = g_settings->getBool("fast_move");
+ continuous_forward = g_settings->getBool("continuous_forward");
+ always_fly_fast = g_settings->getBool("always_fly_fast");
+ aux1_descends = g_settings->getBool("aux1_descends");
+ noclip = g_settings->getBool("noclip");
+}
+
+void Player::settingsChangedCallback(const std::string &name, void *data)
+{
+ ((PlayerSettings *)data)->readGlobalSettings();
+}
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;
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;
// hud for example can be modified by EmergeThread
// and ServerThread
std::mutex m_mutex;
+ PlayerSettings m_player_settings;
};