Make players respect makes_footstep_sound in the object properties
authorTeTpaAka <TeTpaAka@users.noreply.github.com>
Sun, 28 Jun 2015 18:51:59 +0000 (20:51 +0200)
committerEkdohibs <nathanael.courant@laposte.net>
Sat, 6 May 2017 18:16:16 +0000 (20:16 +0200)
src/content_cao.cpp
src/game.cpp
src/localplayer.cpp
src/localplayer.h

index 1bb24aa88a23948698e84fbbde545a39522125f2..c5cb1e21af2a6d9b68641efdac9f4f2141e4c29b 100644 (file)
@@ -1583,6 +1583,10 @@ void GenericCAO::processMessage(const std::string &data)
                        m_initial_tx_basepos_set = true;
                        m_tx_basepos = m_prop.initial_sprite_basepos;
                }
+               if (m_is_local_player) {
+                       LocalPlayer *player = m_env->getLocalPlayer();
+                       player->makes_footstep_sound = m_prop.makes_footstep_sound;
+               }
 
                if ((m_is_player && !m_is_local_player) && m_prop.nametag == "")
                        m_prop.nametag = m_name;
index ace6474566d801c846e092ab4c4abdab475e3ee9..416320e5d29aec5450bf55446e00cec221382fa1 100644 (file)
@@ -476,6 +476,7 @@ class SoundMaker
        ISoundManager *m_sound;
        INodeDefManager *m_ndef;
 public:
+       bool makes_footstep_sound;
        float m_player_step_timer;
 
        SimpleSoundSpec m_player_step_sound;
@@ -485,6 +486,7 @@ public:
        SoundMaker(ISoundManager *sound, INodeDefManager *ndef):
                m_sound(sound),
                m_ndef(ndef),
+               makes_footstep_sound(true),
                m_player_step_timer(0)
        {
        }
@@ -493,7 +495,8 @@ public:
        {
                if (m_player_step_timer <= 0 && m_player_step_sound.exists()) {
                        m_player_step_timer = 0.03;
-                       m_sound->playSound(m_player_step_sound, false);
+                       if (makes_footstep_sound)
+                               m_sound->playSound(m_player_step_sound, false);
                }
        }
 
@@ -3419,11 +3422,14 @@ void Game::updateSound(f32 dtime)
                              camera->getCameraNode()->getUpVector());
        sound->setListenerGain(g_settings->getFloat("sound_volume"));
 
+       LocalPlayer *player = client->getEnv().getLocalPlayer();
 
-       //      Update sound maker
-       soundmaker->step(dtime);
+       // Tell the sound maker whether to make footstep sounds
+       soundmaker->makes_footstep_sound = player->makes_footstep_sound;
 
-       LocalPlayer *player = client->getEnv().getLocalPlayer();
+       //      Update sound maker
+       if (player->makes_footstep_sound)
+               soundmaker->step(dtime);
 
        ClientMap &map = client->getEnv().getClientMap();
        MapNode n = map.getNodeNoEx(player->getFootstepNodePos());
index 9e30aeac8eee5a97fb12f2cf4c8c53a48e081c4d..a909ff40fd854bbe6b310a08751dbde3697f72fa 100644 (file)
@@ -58,6 +58,7 @@ LocalPlayer::LocalPlayer(Client *client, const char *name):
        last_camera_fov(0),
        last_wanted_range(0),
        camera_impact(0.f),
+       makes_footstep_sound(true),
        last_animation(NO_ANIM),
        hotbar_image(""),
        hotbar_selected_image(""),
index dcfefcb1ae2c629f6b7dd70e66c1b6b2e0b16bd7..9cbefae2342eca71f940af1df138ea57ff5e5aae 100644 (file)
@@ -91,6 +91,8 @@ public:
 
        float camera_impact;
 
+       bool makes_footstep_sound;
+
        int last_animation;
        float last_animation_speed;