# HG changeset patch # User Adam Kaminski # Date 1605446926 18000 # Sun Nov 15 08:28:46 2020 -0500 # Node ID 1b967b0845d22e1274db2d96d2010ad368e388a2 # Parent a7015886133535a45f36d2920862bfdd6c320bb0 Added new command "StopSound" to the network protocol, which fixes StopSound() not working in online games. diff -r a70158861335 -r 1b967b0845d2 protocolspec/spec.sounds.txt --- a/protocolspec/spec.sounds.txt Sat Nov 07 23:42:16 2020 -0500 +++ b/protocolspec/spec.sounds.txt Sun Nov 15 08:28:46 2020 -0500 @@ -38,3 +38,9 @@ Command AnnouncerSound String sound EndCommand + +Command StopSound + ExtendedCommand + Actor actor + Short channel +EndCommand diff -r a70158861335 -r 1b967b0845d2 src/cl_main.cpp --- a/src/cl_main.cpp Sat Nov 07 23:42:16 2020 -0500 +++ b/src/cl_main.cpp Sun Nov 15 08:28:46 2020 -0500 @@ -6740,6 +6740,13 @@ //***************************************************************************** // +void ServerCommands::StopSound::Execute() +{ + S_StopSound( actor, channel ); +} + +//***************************************************************************** +// void ServerCommands::StartSectorSequence::Execute() { SN_StartSequence( sector, channel, sequence.GetChars(), modeNum ); diff -r a70158861335 -r 1b967b0845d2 src/network_enums.h --- a/src/network_enums.h Sat Nov 07 23:42:16 2020 -0500 +++ b/src/network_enums.h Sun Nov 15 08:28:46 2020 -0500 @@ -370,6 +370,7 @@ ENUM_ELEMENT ( SVC2_SECRETMARKSECTORFOUND ), ENUM_ELEMENT ( SVC2_SETMAPSKYSCROLLSPEED ), ENUM_ELEMENT ( SVC2_SETLOCALPLAYERJUMPTICS ), + ENUM_ELEMENT ( SVC2_STOPSOUND ), // [BB] Commands necessary for the account system. ENUM_ELEMENT ( SVC2_SRP_USER_START_AUTHENTICATION ), ENUM_ELEMENT ( SVC2_SRP_USER_PROCESS_CHALLENGE ), diff -r a70158861335 -r 1b967b0845d2 src/p_acs.cpp --- a/src/p_acs.cpp Sat Nov 07 23:42:16 2020 -0500 +++ b/src/p_acs.cpp Sun Nov 15 08:28:46 2020 -0500 @@ -6127,9 +6127,13 @@ { S_StopSound(activator, chan); - // [AK] If we're the server, remove the activator's channel from the list of looping channels. + // [AK] If we're the server, tell the clients to stop the sound on the actor. + // Also remove the activator's channel from the list of looping channels. if ( NETWORK_GetState() == NETSTATE_SERVER ) + { + SERVERCOMMANDS_StopSound( activator, chan ); SERVER_RemoveLoopingChannel( activator, chan ); + } } else { @@ -6140,9 +6144,13 @@ { S_StopSound(spot, chan); - // [AK] If we're the server, remove the actor's channel from the list of looping channels. + // [AK] If we're the server, tell the clients to stop the sound on the actor. + // Also remove the actor's channel from the list of looping channels. if ( NETWORK_GetState() == NETSTATE_SERVER ) + { + SERVERCOMMANDS_StopSound( spot, chan ); SERVER_RemoveLoopingChannel( spot, chan ); + } } } } diff -r a70158861335 -r 1b967b0845d2 src/sv_commands.cpp --- a/src/sv_commands.cpp Sat Nov 07 23:42:16 2020 -0500 +++ b/src/sv_commands.cpp Sun Nov 15 08:28:46 2020 -0500 @@ -3172,6 +3172,20 @@ } //***************************************************************************** +// +void SERVERCOMMANDS_StopSound( AActor *pActor, LONG lChannel, ULONG ulPlayerExtra, ServerCommandFlags flags ) +{ + // [AK] The actor must have a NetID so we can tell clients to stop the sound on their channel. + if ( pActor == NULL || pActor->lNetID == -1 ) + return; + + NetCommand command( SVC2_STOPSOUND ); + command.addShort( pActor->lNetID ); + command.addShort( lChannel ); + command.sendCommandToClients( ulPlayerExtra, flags ); +} + +//***************************************************************************** //***************************************************************************** // void SERVERCOMMANDS_StartSectorSequence( sector_t *pSector, const int Channel, const char *pszSequence, const int Modenum, ULONG ulPlayerExtra, ServerCommandFlags flags ) diff -r a70158861335 -r 1b967b0845d2 src/sv_commands.h --- a/src/sv_commands.h Sat Nov 07 23:42:16 2020 -0500 +++ b/src/sv_commands.h Sun Nov 15 08:28:46 2020 -0500 @@ -311,6 +311,7 @@ void SERVERCOMMANDS_SoundSector( sector_t *sector, int channel, const char *sound, float volume, float attenuation, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); void SERVERCOMMANDS_SoundPoint( LONG lX, LONG lY, LONG lZ, LONG lChannel, const char *pszSound, float fVolume, float fAttenuation, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); void SERVERCOMMANDS_AnnouncerSound( const char *pszSound, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); +void SERVERCOMMANDS_StopSound( AActor *pActor, LONG lChannel, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); // Sector sequence commands. These handle sector sound sequences. void SERVERCOMMANDS_StartSectorSequence( sector_t *pSector, const int Channel, const char *pszSequence, const int Modenum, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 );