diff --git a/src/client.cpp b/src/client.cpp index 579d841..5af0671 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1023,8 +1023,11 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id) break; case TOCLIENT_PLAYER_ANIMATION: { - u16 peer_id = readU16(&data[2]); - u8 anim_id = readU8(&data[4]); + std::string datastring((char*)&data[2], datasize-2); + std::istringstream is(datastring, std::ios_base::binary); + u16 peer_id = readU16(is); + u8 anim_id = readU8(is); + content_t pointed = readU16(is); Player *player = m_env.getPlayer(peer_id); @@ -1039,7 +1042,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id) infostream<<"Client: Adding new player " <updateAnim(anim_id); + player->updateAnim(anim_id,pointed); } break; case TOCLIENT_PLAYERHP: diff --git a/src/player.cpp b/src/player.cpp index a3e15cb..3691aab 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -464,6 +464,7 @@ RemotePlayer::RemotePlayer( m_text(NULL), m_wield(NULL), m_anim_id(PLAYERANIM_STAND), + m_pointed(CONTENT_IGNORE), m_next_foot(0) { m_box = core::aabbox3d(-BS/2,0,-BS/2,BS/2,BS*2,BS/2); @@ -606,7 +607,7 @@ void RemotePlayer::move(f32 dtime, Map &map, f32 pos_max_d) } /* roughly sort of when a dig sound should probably be heard, maybe */ if (frame == 214 || frame == 205 || frame == 193) { - sound_playDig(CMT_STONE,m_showpos); + sound_playDig(m_pointed,m_showpos); } if ( diff --git a/src/player.h b/src/player.h index 9f23c5e..69b5589 100644 --- a/src/player.h +++ b/src/player.h @@ -146,7 +146,7 @@ public: light = light_at_pos; } - virtual void updateAnim(u8 anim_id) + virtual void updateAnim(u8 anim_id, content_t pointed) {} // NOTE: Use peer_id == 0 for disconnected @@ -377,7 +377,12 @@ public: virtual void wieldItem(u16 item); - virtual void updateAnim(u8 anim_id) {m_anim_id = anim_id;} + virtual void updateAnim(u8 anim_id, content_t pointed) + { + m_anim_id = anim_id; + if (pointed != CONTENT_IGNORE) + m_pointed = pointed; + } virtual void updateLight(u8 light_at_pos) { @@ -414,6 +419,7 @@ private: v3f m_showpos; v3f m_camera_offset; u8 m_anim_id; + content_t m_pointed; int m_next_foot; }; diff --git a/src/server.cpp b/src/server.cpp index 3efa298..39b5aea 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2507,8 +2507,8 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) */ if(action == 0) { - SendPlayerAnim(player,PLAYERANIM_DIG); MapNode n = m_env.getMap().getNodeNoEx(p_under); + SendPlayerAnim(player,PLAYERANIM_DIG,n.getContent()); InventoryItem *wield = (InventoryItem*)player->getWieldItem(); // no on-punch events with a mese pick, it will have dug the item // on the first hit anyway @@ -5349,7 +5349,7 @@ std::string getWieldedItemString(const Player *player) return os.str(); } -void Server::SendPlayerAnim(const Player* player, u8 animation_id) +void Server::SendPlayerAnim(const Player* player, u8 animation_id, content_t pointed) { DSTACK(__FUNCTION_NAME); @@ -5360,6 +5360,7 @@ void Server::SendPlayerAnim(const Player* player, u8 animation_id) writeU16(os, TOCLIENT_PLAYER_ANIMATION); writeU16(os, player->peer_id); writeU8(os, animation_id); + writeU16(os, pointed); // Make data buffer std::string s = os.str(); diff --git a/src/server.h b/src/server.h index 9d84b91..d5504a4 100644 --- a/src/server.h +++ b/src/server.h @@ -518,7 +518,7 @@ private: void SendPlayerInfos(); void SendInventory(u16 peer_id, bool full=false); // send animation info about player to all - void SendPlayerAnim(const Player *player, u8 animation_id); + void SendPlayerAnim(const Player *player, u8 animation_id, content_t pointed=CONTENT_IGNORE); // send wielded item info about all players to all players void SendPlayerItems(); // send wielded item info about a player to all players