1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-11 17:51:04 +00:00

Add physics overrides for walk speed and Fast Mode (#14475)

Co-authored-by: Wuzzy <Wuzzy@disroot.org>
This commit is contained in:
grorp 2024-04-30 13:50:01 +02:00 committed by GitHub
parent c044a3c1ca
commit 2bdd0a6bdb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 94 additions and 33 deletions

View file

@ -1804,6 +1804,7 @@ void GenericCAO::processMessage(const std::string &data)
bool sneak_glitch = !readU8(is);
bool new_move = !readU8(is);
// new overrides since 5.8.0
float override_speed_climb = readF32(is);
float override_speed_crouch = readF32(is);
float override_liquid_fluidity = readF32(is);
@ -1811,7 +1812,6 @@ void GenericCAO::processMessage(const std::string &data)
float override_liquid_sink = readF32(is);
float override_acceleration_default = readF32(is);
float override_acceleration_air = readF32(is);
// fallback for new overrides (since 5.8.0)
if (is.eof()) {
override_speed_climb = 1.0f;
override_speed_crouch = 1.0f;
@ -1822,6 +1822,16 @@ void GenericCAO::processMessage(const std::string &data)
override_acceleration_air = 1.0f;
}
// new overrides since 5.9.0
float override_speed_fast = readF32(is);
float override_acceleration_fast = readF32(is);
float override_speed_walk = readF32(is);
if (is.eof()) {
override_speed_fast = 1.0f;
override_acceleration_fast = 1.0f;
override_speed_walk = 1.0f;
}
if (m_is_local_player) {
auto &phys = m_env->getLocalPlayer()->physics_override;
phys.speed = override_speed;
@ -1837,6 +1847,9 @@ void GenericCAO::processMessage(const std::string &data)
phys.liquid_sink = override_liquid_sink;
phys.acceleration_default = override_acceleration_default;
phys.acceleration_air = override_acceleration_air;
phys.speed_fast = override_speed_fast;
phys.acceleration_fast = override_acceleration_fast;
phys.speed_walk = override_speed_walk;
}
} else if (cmd == AO_CMD_SET_ANIMATION) {
// TODO: change frames send as v2s32 value