Skip to content

Commit aa5ec2e

Browse files
random-geekparamat
authored andcommittedDec 31, 2018
Extend pitch fly mode to swimming (#7943)
1 parent 7d7ccf5 commit aa5ec2e

12 files changed

+38
-28
lines changed
 

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Some can be changed in the key config dialog in the settings tab.
6565
| + | Increase view range |
6666
| - | Decrease view range |
6767
| K | Enable/disable fly mode (needs fly privilege) |
68-
| L | Enable/disable pitch fly mode |
68+
| L | Enable/disable pitch move mode |
6969
| J | Enable/disable fast mode (needs fast privilege) |
7070
| H | Enable/disable noclip mode (needs noclip privilege) |
7171
| E | Move fast in fast mode |

‎builtin/settingtypes.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ enable_build_where_you_stand (Build inside player) bool false
7272
# This requires the "fly" privilege on the server.
7373
free_move (Flying) bool false
7474

75-
# If enabled together with fly mode, makes move directions relative to the player's pitch.
76-
pitch_fly (Pitch fly mode) bool false
75+
# If enabled, makes move directions relative to the player's pitch when flying or swimming.
76+
pitch_move (Pitch move mode) bool false
7777

7878
# Fast movement (via the "special" key).
7979
# This requires the "fast" privilege on the server.
@@ -211,9 +211,9 @@ keymap_rangeselect (Range select key) key KEY_KEY_R
211211
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
212212
keymap_freemove (Fly key) key KEY_KEY_K
213213

214-
# Key for toggling pitch fly mode.
214+
# Key for toggling pitch move mode.
215215
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
216-
keymap_pitchfly (Pitch fly key) key KEY_KEY_L
216+
keymap_pitchmove (Pitch move key) key KEY_KEY_L
217217

218218
# Key for toggling fast mode.
219219
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3

‎minetest.conf.example

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
# type: bool
2727
# free_move = false
2828

29-
# If enabled together with fly mode, makes move directions relative to the player's pitch.
29+
# If enabled, makes move directions relative to the player's pitch when flying or swimming.
3030
# type: bool
31-
# pitch_fly = false
31+
# pitch_move = false
3232

3333
# Fast movement (via the "special" key).
3434
# This requires the "fast" privilege on the server.
@@ -202,10 +202,10 @@
202202
# type: key
203203
# keymap_freemove = KEY_KEY_K
204204

205-
# Key for toggling pitch fly mode.
205+
# Key for toggling pitch move mode.
206206
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
207207
# type: key
208-
# keymap_pitchfly = KEY_KEY_L
208+
# keymap_pitchmove = KEY_KEY_L
209209

210210
# Key for toggling fast mode.
211211
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3

‎src/client/clientenvironment.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ void ClientEnvironment::step(float dtime)
170170
lplayer->physics_override_gravity * dtime_part * 2.0f;
171171

172172
// Liquid floating / sinking
173-
if (lplayer->in_liquid && !lplayer->swimming_vertical)
173+
if (lplayer->in_liquid && !lplayer->swimming_vertical &&
174+
!lplayer->swimming_pitch)
174175
speed.Y -= lplayer->movement_liquid_sink * dtime_part * 2.0f;
175176

176177
// Liquid resistance

‎src/client/game.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ class Game {
702702
void openConsole(float scale, const wchar_t *line=NULL);
703703
void toggleFreeMove();
704704
void toggleFreeMoveAlt();
705-
void togglePitchFly();
705+
void togglePitchMove();
706706
void toggleFast();
707707
void toggleNoClip();
708708
void toggleCinematic();
@@ -1898,8 +1898,8 @@ void Game::processKeyInput()
18981898
toggleFreeMove();
18991899
} else if (wasKeyDown(KeyType::JUMP)) {
19001900
toggleFreeMoveAlt();
1901-
} else if (wasKeyDown(KeyType::PITCHFLY)) {
1902-
togglePitchFly();
1901+
} else if (wasKeyDown(KeyType::PITCHMOVE)) {
1902+
togglePitchMove();
19031903
} else if (wasKeyDown(KeyType::FASTMOVE)) {
19041904
toggleFast();
19051905
} else if (wasKeyDown(KeyType::NOCLIP)) {
@@ -2109,15 +2109,15 @@ void Game::toggleFreeMoveAlt()
21092109
}
21102110

21112111

2112-
void Game::togglePitchFly()
2112+
void Game::togglePitchMove()
21132113
{
2114-
bool pitch_fly = !g_settings->getBool("pitch_fly");
2115-
g_settings->set("pitch_fly", bool_to_cstr(pitch_fly));
2114+
bool pitch_move = !g_settings->getBool("pitch_move");
2115+
g_settings->set("pitch_move", bool_to_cstr(pitch_move));
21162116

2117-
if (pitch_fly) {
2118-
m_game_ui->showTranslatedStatusText("Pitch fly mode enabled");
2117+
if (pitch_move) {
2118+
m_game_ui->showTranslatedStatusText("Pitch move mode enabled");
21192119
} else {
2120-
m_game_ui->showTranslatedStatusText("Pitch fly mode disabled");
2120+
m_game_ui->showTranslatedStatusText("Pitch move mode disabled");
21212121
}
21222122
}
21232123

‎src/client/inputhandler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void KeyCache::populate()
4848
key[KeyType::CONSOLE] = getKeySetting("keymap_console");
4949
key[KeyType::MINIMAP] = getKeySetting("keymap_minimap");
5050
key[KeyType::FREEMOVE] = getKeySetting("keymap_freemove");
51-
key[KeyType::PITCHFLY] = getKeySetting("keymap_pitchfly");
51+
key[KeyType::PITCHMOVE] = getKeySetting("keymap_pitchmove");
5252
key[KeyType::FASTMOVE] = getKeySetting("keymap_fastmove");
5353
key[KeyType::NOCLIP] = getKeySetting("keymap_noclip");
5454
key[KeyType::HOTBAR_PREV] = getKeySetting("keymap_hotbar_previous");

‎src/client/keys.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class KeyType
4747
CONSOLE,
4848
MINIMAP,
4949
FREEMOVE,
50-
PITCHFLY,
50+
PITCHMOVE,
5151
FASTMOVE,
5252
NOCLIP,
5353
HOTBAR_PREV,

‎src/client/localplayer.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ void LocalPlayer::applyControl(float dtime, Environment *env)
468468
{
469469
// Clear stuff
470470
swimming_vertical = false;
471+
swimming_pitch = false;
471472

472473
setPitch(control.pitch);
473474
setYaw(control.yaw);
@@ -492,7 +493,7 @@ void LocalPlayer::applyControl(float dtime, Environment *env)
492493

493494
bool free_move = fly_allowed && player_settings.free_move;
494495
bool fast_move = fast_allowed && player_settings.fast_move;
495-
bool pitch_fly = free_move && player_settings.pitch_fly;
496+
bool pitch_move = (free_move || in_liquid) && player_settings.pitch_move;
496497
// When aux1_descends is enabled the fast key is used to go down, so fast isn't possible
497498
bool fast_climb = fast_move && control.aux1 && !player_settings.aux1_descends;
498499
bool continuous_forward = player_settings.continuous_forward;
@@ -685,10 +686,17 @@ void LocalPlayer::applyControl(float dtime, Environment *env)
685686
if (!free_move)
686687
slip_factor = getSlipFactor(env, speedH);
687688

689+
// Don't sink when swimming in pitch mode
690+
if (pitch_move && in_liquid) {
691+
v3f controlSpeed = speedH + speedV;
692+
if (controlSpeed.getLength() > 0.01f)
693+
swimming_pitch = true;
694+
}
695+
688696
// Accelerate to target speed with maximum increment
689697
accelerate((speedH + speedV) * physics_override_speed,
690698
incH * physics_override_speed * slip_factor, incV * physics_override_speed,
691-
pitch_fly);
699+
pitch_move);
692700
}
693701

694702
v3s16 LocalPlayer::getStandingNodePos()

‎src/client/localplayer.h

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class LocalPlayer : public Player
6262
u8 liquid_viscosity = 0;
6363
bool is_climbing = false;
6464
bool swimming_vertical = false;
65+
bool swimming_pitch = false;
6566

6667
float physics_override_speed = 1.0f;
6768
float physics_override_jump = 1.0f;

‎src/defaultsettings.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void set_default_settings(Settings *settings)
4343
settings->setDefault("meshgen_block_cache_size", "20");
4444
settings->setDefault("enable_vbo", "true");
4545
settings->setDefault("free_move", "false");
46-
settings->setDefault("pitch_fly", "false");
46+
settings->setDefault("pitch_move", "false");
4747
settings->setDefault("fast_move", "false");
4848
settings->setDefault("noclip", "false");
4949
settings->setDefault("screenshot_path", ".");
@@ -81,7 +81,7 @@ void set_default_settings(Settings *settings)
8181
settings->setDefault("keymap_console", "KEY_F10");
8282
settings->setDefault("keymap_rangeselect", "KEY_KEY_R");
8383
settings->setDefault("keymap_freemove", "KEY_KEY_K");
84-
settings->setDefault("keymap_pitchfly", "KEY_KEY_L");
84+
settings->setDefault("keymap_pitchmove", "KEY_KEY_L");
8585
settings->setDefault("keymap_fastmove", "KEY_KEY_J");
8686
settings->setDefault("keymap_noclip", "KEY_KEY_H");
8787
settings->setDefault("keymap_hotbar_next", "KEY_KEY_N");

‎src/player.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ void Player::clearHud()
139139
void PlayerSettings::readGlobalSettings()
140140
{
141141
free_move = g_settings->getBool("free_move");
142-
pitch_fly = g_settings->getBool("pitch_fly");
142+
pitch_move = g_settings->getBool("pitch_move");
143143
fast_move = g_settings->getBool("fast_move");
144144
continuous_forward = g_settings->getBool("continuous_forward");
145145
always_fly_fast = g_settings->getBool("always_fly_fast");

‎src/player.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ struct PlayerControl
8787
struct PlayerSettings
8888
{
8989
bool free_move = false;
90-
bool pitch_fly = false;
90+
bool pitch_move = false;
9191
bool fast_move = false;
9292
bool continuous_forward = false;
9393
bool always_fly_fast = false;
@@ -96,7 +96,7 @@ struct PlayerSettings
9696
bool autojump = false;
9797

9898
const std::string setting_names[8] = {
99-
"free_move", "pitch_fly", "fast_move", "continuous_forward", "always_fly_fast",
99+
"free_move", "pitch_move", "fast_move", "continuous_forward", "always_fly_fast",
100100
"aux1_descends", "noclip", "autojump"
101101
};
102102
void readGlobalSettings();

0 commit comments

Comments
 (0)
Please sign in to comment.