send node type with animation updates, so remote player dig sound is correct

This commit is contained in:
darkrose 2015-04-24 14:44:46 +10:00
parent 7bcb6eb6d3
commit de16a5654e
5 changed files with 20 additions and 9 deletions

View File

@ -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 " <<peer_id<<std::endl;
}
player->updateAnim(anim_id);
player->updateAnim(anim_id,pointed);
}
break;
case TOCLIENT_PLAYERHP:

View File

@ -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<f32>(-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 (

View File

@ -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;
};

View File

@ -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();

View File

@ -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