Closed ChillerDragon closed 6 months ago
This would fix it but it is not in the translation layer but in the gameclient.cpp so it is not nice
diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp
index 21189de5a..b1744895b 100644
--- a/src/game/client/gameclient.cpp
+++ b/src/game/client/gameclient.cpp
@@ -2141,6 +2141,8 @@ void CGameClient::OnPredict()
m_Sounds.PlayAndRecord(CSounds::CHN_WORLD, SOUND_HOOK_ATTACH_GROUND, 1.0f, Pos);
if(Events & COREEVENT_HOOK_HIT_NOHOOK)
m_Sounds.PlayAndRecord(CSounds::CHN_WORLD, SOUND_HOOK_NOATTACH, 1.0f, Pos);
+ if(Events & COREEVENT_HOOK_ATTACH_PLAYER && Client()->IsSixup())
+ m_Sounds.PlayAndRecord(CSounds::CHN_WORLD, SOUND_HOOK_ATTACH_PLAYER, 1.0f, Pos);
}
}
diff --git a/src/game/client/sixup_translate_snapshot.cpp b/src/game/client/sixup_translate_snapshot.cpp
index 1cbb03f18..bf9b5ca98 100644
--- a/src/game/client/sixup_translate_snapshot.cpp
+++ b/src/game/client/sixup_translate_snapshot.cpp
@@ -243,18 +243,18 @@ int CGameClient::TranslateSnap(CSnapshot *pSnapDstSix, CSnapshot *pSnapSrcSeven,
Char6.m_Emote = pChar7->m_Emote;
Char6.m_AttackTick = pChar7->m_AttackTick;
- if(pChar7->m_TriggeredEvents & protocol7::COREEVENTFLAG_HOOK_ATTACH_PLAYER)
- {
- void *pEvent = Builder.NewItem(NETEVENTTYPE_SOUNDWORLD, pItem7->Id(), sizeof(CNetEvent_SoundWorld));
- if(!pEvent)
- return -7;
-
- CNetEvent_SoundWorld Sound = {};
- Sound.m_X = pChar7->m_X;
- Sound.m_Y = pChar7->m_Y;
- Sound.m_SoundId = SOUND_HOOK_ATTACH_PLAYER;
- mem_copy(pEvent, &Sound, sizeof(CNetEvent_SoundWorld));
- }
+ // if(pChar7->m_TriggeredEvents & protocol7::COREEVENTFLAG_HOOK_ATTACH_PLAYER)
+ // {
+ // void *pEvent = Builder.NewItem(NETEVENTTYPE_SOUNDWORLD, pItem7->Id(), sizeof(CNetEvent_SoundWorld));
+ // if(!pEvent)
+ // return -7;
+
+ // CNetEvent_SoundWorld Sound = {};
+ // Sound.m_X = pChar7->m_X;
+ // Sound.m_Y = pChar7->m_Y;
+ // Sound.m_SoundId = SOUND_HOOK_ATTACH_PLAYER;
+ // mem_copy(pEvent, &Sound, sizeof(CNetEvent_SoundWorld));
+ // }
if(TranslationContext.m_aLocalClientId[Conn] != pItem7->Id())
{
The vanilla client plays back the sound just fine on ddnet servers because it plays the sound in the gameclient.cpp in the OnPredict method. Which called the gamecore tick that checked if a hook was attached and then sets the triggered events flag.
This approach is hard to do in the translation layer because we don't want to duplicate the whole prediction process.
https://github.com/ChillerDragon/ddnet/tree/pr_07_client_hooks_sound_ddnet_servers
Hooking others sound on ddnet servers is bugged. But I fixed it on vanilla servers by adding the sound snap item even if the triggered events are on another player.
The ddnet fix might need a ddnet server change. Please investigate that. As of right now it seems that the triggered events flag is not sent on every hook by ddnet. There seems to be some sort of ratelimit or hiccup. While vanilla servers set the flag consistently. Maybe it does not detect it as change and depends on another change to happen.