Open anzz1 opened 7 months ago
Interesting. I think music persisting between maps in multiplayer is technically correct behavior and is what would've probably happened in ancient versions of GoldSrc, but I can see how multiplayer mods might rely on the music stopping.
I'll look into implementing the fix at some point.
As the music fix always lets music continue playing on connect/transition if it's not gamestartup.mp3, this introduces an issue where a server can play some music file and it continues playing after map changes.
To fix this, apply the music fix on single player only. One way is to check for
(server_state_t) svs.maxclients == 1
in the function and act accordingly. There is also fieldintermission
in client_state_t which probably would also work, but I find check for maxclients==1 to check for SP/MP works just fine.Here is some example code. Note also that you can't install the hook for
CGameUI::ConnectToServer
beforeCBaseUI::Start
has been called as otherwise the GameUI.dll module isn't loaded yet. This can be done for example inCL_Init
.Offsets are hardcoded for steam_legacy branch (build 8684) but it can be adapted to use signatures.
So for clarification, this stops playing the music on connect/transition if either 1) current file is gamestartup.mp3 2) is playing MP game
This way sound doesn't cut off in singleplayer game map transitions, but also doesn't keep playing in multiplayer servers after map (or server) change.