mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 10:03:45 +01: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
@ -1032,7 +1032,7 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
|
|||||||
rot_translator.val_current = m_rotation;
|
rot_translator.val_current = m_rotation;
|
||||||
|
|
||||||
if (m_is_visible) {
|
if (m_is_visible) {
|
||||||
int old_anim = player->last_animation;
|
LocalPlayerAnimation old_anim = player->last_animation;
|
||||||
float old_anim_speed = player->last_animation_speed;
|
float old_anim_speed = player->last_animation_speed;
|
||||||
m_velocity = v3f(0,0,0);
|
m_velocity = v3f(0,0,0);
|
||||||
m_acceleration = 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)) {
|
if (walking && (controls.dig || controls.place)) {
|
||||||
new_anim = player->local_animations[3];
|
new_anim = player->local_animations[3];
|
||||||
player->last_animation = WD_ANIM;
|
player->last_animation = LocalPlayerAnimation::WD_ANIM;
|
||||||
} else if (walking) {
|
} else if (walking) {
|
||||||
new_anim = player->local_animations[1];
|
new_anim = player->local_animations[1];
|
||||||
player->last_animation = WALK_ANIM;
|
player->last_animation = LocalPlayerAnimation::WALK_ANIM;
|
||||||
} else if (controls.dig || controls.place) {
|
} else if (controls.dig || controls.place) {
|
||||||
new_anim = player->local_animations[2];
|
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
|
// Apply animations if input detected and not attached
|
||||||
@ -1079,9 +1079,9 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
|
|||||||
m_animation_speed = new_speed;
|
m_animation_speed = new_speed;
|
||||||
player->last_animation_speed = m_animation_speed;
|
player->last_animation_speed = m_animation_speed;
|
||||||
} else {
|
} 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];
|
m_animation_range = player->local_animations[0];
|
||||||
updateAnimation();
|
updateAnimation();
|
||||||
}
|
}
|
||||||
@ -1090,7 +1090,8 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
|
|||||||
// Update local player animations
|
// Update local player animations
|
||||||
if ((player->last_animation != old_anim ||
|
if ((player->last_animation != old_anim ||
|
||||||
m_animation_speed != old_anim_speed) &&
|
m_animation_speed != old_anim_speed) &&
|
||||||
player->last_animation != NO_ANIM && allow_update)
|
player->last_animation != LocalPlayerAnimation::NO_ANIM &&
|
||||||
|
allow_update)
|
||||||
updateAnimation();
|
updateAnimation();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1801,7 +1802,7 @@ void GenericCAO::processMessage(const std::string &data)
|
|||||||
updateAnimation();
|
updateAnimation();
|
||||||
} else {
|
} else {
|
||||||
LocalPlayer *player = m_env->getLocalPlayer();
|
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_range = v2s32((s32)range.X, (s32)range.Y);
|
||||||
m_animation_speed = readF32(is);
|
m_animation_speed = readF32(is);
|
||||||
|
@ -34,7 +34,7 @@ class ClientEnvironment;
|
|||||||
class IGameDef;
|
class IGameDef;
|
||||||
struct collisionMoveResult;
|
struct collisionMoveResult;
|
||||||
|
|
||||||
enum LocalPlayerAnimations
|
enum class LocalPlayerAnimation
|
||||||
{
|
{
|
||||||
NO_ANIM,
|
NO_ANIM,
|
||||||
WALK_ANIM,
|
WALK_ANIM,
|
||||||
@ -90,7 +90,7 @@ public:
|
|||||||
|
|
||||||
bool makes_footstep_sound = true;
|
bool makes_footstep_sound = true;
|
||||||
|
|
||||||
int last_animation = NO_ANIM;
|
LocalPlayerAnimation last_animation = LocalPlayerAnimation::NO_ANIM;
|
||||||
float last_animation_speed = 0.0f;
|
float last_animation_speed = 0.0f;
|
||||||
|
|
||||||
std::string hotbar_image = "";
|
std::string hotbar_image = "";
|
||||||
|
@ -34,6 +34,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "util/strfnd.h"
|
#include "util/strfnd.h"
|
||||||
#include "client/clientevent.h"
|
#include "client/clientevent.h"
|
||||||
#include "client/sound.h"
|
#include "client/sound.h"
|
||||||
|
#include "client/localplayer.h"
|
||||||
#include "network/clientopcodes.h"
|
#include "network/clientopcodes.h"
|
||||||
#include "network/connection.h"
|
#include "network/connection.h"
|
||||||
#include "network/networkpacket.h"
|
#include "network/networkpacket.h"
|
||||||
@ -1508,7 +1509,7 @@ void Client::handleCommand_LocalPlayerAnimations(NetworkPacket* pkt)
|
|||||||
*pkt >> player->local_animations[3];
|
*pkt >> player->local_animations[3];
|
||||||
*pkt >> player->local_animation_speed;
|
*pkt >> player->local_animation_speed;
|
||||||
|
|
||||||
player->last_animation = -1;
|
player->last_animation = LocalPlayerAnimation::NO_ANIM;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::handleCommand_EyeOffset(NetworkPacket* pkt)
|
void Client::handleCommand_EyeOffset(NetworkPacket* pkt)
|
||||||
|
Loading…
Reference in New Issue
Block a user