mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-06 17:41:04 +00:00
Fix local animations not resetting
Converts `LocalPlayerAnimation` to a scoped enum to prevent such bugs in the future
This commit is contained in:
parent
ff498fc206
commit
25ef8f3934
3 changed files with 13 additions and 11 deletions
|
@ -1032,7 +1032,7 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
|
|||
rot_translator.val_current = m_rotation;
|
||||
|
||||
if (m_is_visible) {
|
||||
int old_anim = player->last_animation;
|
||||
LocalPlayerAnimation old_anim = player->last_animation;
|
||||
float old_anim_speed = player->last_animation_speed;
|
||||
m_velocity = v3f(0,0,0);
|
||||
m_acceleration = v3f(0,0,0);
|
||||
|
@ -1062,13 +1062,13 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
|
|||
|
||||
if (walking && (controls.dig || controls.place)) {
|
||||
new_anim = player->local_animations[3];
|
||||
player->last_animation = WD_ANIM;
|
||||
player->last_animation = LocalPlayerAnimation::WD_ANIM;
|
||||
} else if (walking) {
|
||||
new_anim = player->local_animations[1];
|
||||
player->last_animation = WALK_ANIM;
|
||||
player->last_animation = LocalPlayerAnimation::WALK_ANIM;
|
||||
} else if (controls.dig || controls.place) {
|
||||
new_anim = player->local_animations[2];
|
||||
player->last_animation = DIG_ANIM;
|
||||
player->last_animation = LocalPlayerAnimation::DIG_ANIM;
|
||||
}
|
||||
|
||||
// Apply animations if input detected and not attached
|
||||
|
@ -1079,9 +1079,9 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
|
|||
m_animation_speed = new_speed;
|
||||
player->last_animation_speed = m_animation_speed;
|
||||
} else {
|
||||
player->last_animation = NO_ANIM;
|
||||
player->last_animation = LocalPlayerAnimation::NO_ANIM;
|
||||
|
||||
if (old_anim != NO_ANIM) {
|
||||
if (old_anim != LocalPlayerAnimation::NO_ANIM) {
|
||||
m_animation_range = player->local_animations[0];
|
||||
updateAnimation();
|
||||
}
|
||||
|
@ -1090,7 +1090,8 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
|
|||
// Update local player animations
|
||||
if ((player->last_animation != old_anim ||
|
||||
m_animation_speed != old_anim_speed) &&
|
||||
player->last_animation != NO_ANIM && allow_update)
|
||||
player->last_animation != LocalPlayerAnimation::NO_ANIM &&
|
||||
allow_update)
|
||||
updateAnimation();
|
||||
|
||||
}
|
||||
|
@ -1801,7 +1802,7 @@ void GenericCAO::processMessage(const std::string &data)
|
|||
updateAnimation();
|
||||
} else {
|
||||
LocalPlayer *player = m_env->getLocalPlayer();
|
||||
if(player->last_animation == NO_ANIM)
|
||||
if(player->last_animation == LocalPlayerAnimation::NO_ANIM)
|
||||
{
|
||||
m_animation_range = v2s32((s32)range.X, (s32)range.Y);
|
||||
m_animation_speed = readF32(is);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue