aboutsummaryrefslogtreecommitdiff
path: root/src/client/game.cpp
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2022-01-09 18:46:36 +0100
committerGitHub <noreply@github.com>2022-01-09 18:46:36 +0100
commit5eb45e1ea03c6104f007efec6dd9c351f310193d (patch)
tree28a40addf99493aedfbf67e4d85fa6cf88723419 /src/client/game.cpp
parent76dbd0d2d04712dcad4f7c6afecb97fa8d662d6d (diff)
downloadminetest-5eb45e1ea03c6104f007efec6dd9c351f310193d.tar.gz
minetest-5eb45e1ea03c6104f007efec6dd9c351f310193d.tar.bz2
minetest-5eb45e1ea03c6104f007efec6dd9c351f310193d.zip
Restore pass-through of direction keys (#11924)
This moves relevant code into the PlayerControl class and gets rid of separate keyPressed variable.
Diffstat (limited to 'src/client/game.cpp')
-rw-r--r--src/client/game.cpp36
1 files changed, 4 insertions, 32 deletions
diff --git a/src/client/game.cpp b/src/client/game.cpp
index f62d26e8f..182dc3815 100644
--- a/src/client/game.cpp
+++ b/src/client/game.cpp
@@ -2481,6 +2481,10 @@ void Game::updatePlayerControl(const CameraOrientation &cam)
//TimeTaker tt("update player control", NULL, PRECISION_NANO);
PlayerControl control(
+ isKeyDown(KeyType::FORWARD),
+ isKeyDown(KeyType::BACKWARD),
+ isKeyDown(KeyType::LEFT),
+ isKeyDown(KeyType::RIGHT),
isKeyDown(KeyType::JUMP) || player->getAutojump(),
isKeyDown(KeyType::AUX1),
isKeyDown(KeyType::SNEAK),
@@ -2511,39 +2515,7 @@ void Game::updatePlayerControl(const CameraOrientation &cam)
}
#endif
- u32 keypress_bits = (
- ( (u32)(control.jump & 0x1) << 4) |
- ( (u32)(control.aux1 & 0x1) << 5) |
- ( (u32)(control.sneak & 0x1) << 6) |
- ( (u32)(control.dig & 0x1) << 7) |
- ( (u32)(control.place & 0x1) << 8) |
- ( (u32)(control.zoom & 0x1) << 9)
- );
-
- // Set direction keys to ensure mod compatibility
- if (control.movement_speed > 0.001f) {
- float absolute_direction;
-
- // Check in original orientation (absolute value indicates forward / backward)
- absolute_direction = abs(control.movement_direction);
- if (absolute_direction < (3.0f / 8.0f * M_PI))
- keypress_bits |= (u32)(0x1 << 0); // Forward
- if (absolute_direction > (5.0f / 8.0f * M_PI))
- keypress_bits |= (u32)(0x1 << 1); // Backward
-
- // Rotate entire coordinate system by 90 degrees (absolute value indicates left / right)
- absolute_direction = control.movement_direction + M_PI_2;
- if (absolute_direction >= M_PI)
- absolute_direction -= 2 * M_PI;
- absolute_direction = abs(absolute_direction);
- if (absolute_direction < (3.0f / 8.0f * M_PI))
- keypress_bits |= (u32)(0x1 << 2); // Left
- if (absolute_direction > (5.0f / 8.0f * M_PI))
- keypress_bits |= (u32)(0x1 << 3); // Right
- }
-
client->setPlayerControl(control);
- player->keyPressed = keypress_bits;
//tt.stop();
}