# HG changeset patch # User Adam Kaminski # Date 1604064840 14400 # Fri Oct 30 09:34:00 2020 -0400 # Node ID a423beb3f31804d1cd7555091204d7df65c32143 # Parent 7fdf32e9c97e8d9f08d57fb497dc5ce4acb88c8f Added new command "SetThingSpecies" to the network protocol so that an actor's species property is updated to the clients in an online game when it's changed, particularly with APROP_SPECIES from SetActorProperty. diff -r 7fdf32e9c97e -r a423beb3f318 protocolspec/spec.things.txt --- a/protocolspec/spec.things.txt Wed Oct 28 12:06:27 2020 -0400 +++ b/protocolspec/spec.things.txt Fri Oct 30 09:34:00 2020 -0400 @@ -290,6 +290,12 @@ EndIf EndCommand +Command SetThingSpecies + ExtendedCommand + Actor actor + String species +EndCommand + Command ThingIsCorpse Actor actor # [TP] TODO: Does this really need to be sent? The client should be able to deduce this. diff -r 7fdf32e9c97e -r a423beb3f318 src/cl_main.cpp --- a/src/cl_main.cpp Wed Oct 28 12:06:27 2020 -0400 +++ b/src/cl_main.cpp Fri Oct 30 09:34:00 2020 -0400 @@ -5283,6 +5283,13 @@ //***************************************************************************** // +void ServerCommands::SetThingSpecies::Execute() +{ + actor->Species = species; +} + +//***************************************************************************** +// void ServerCommands::SetWeaponAmmoGive::Execute() { weapon->AmmoGive1 = ammoGive1; diff -r 7fdf32e9c97e -r a423beb3f318 src/network_enums.h --- a/src/network_enums.h Wed Oct 28 12:06:27 2020 -0400 +++ b/src/network_enums.h Fri Oct 30 09:34:00 2020 -0400 @@ -353,6 +353,7 @@ ENUM_ELEMENT ( SVC2_BUILDSTAIR ), ENUM_ELEMENT ( SVC2_SETMUGSHOTSTATE ), ENUM_ELEMENT ( SVC2_SETTHINGSCALE ), + ENUM_ELEMENT ( SVC2_SETTHINGSPECIES ), ENUM_ELEMENT ( SVC2_SETMAPNUMTOTALSECRETS ), ENUM_ELEMENT ( SVC2_SOUNDSECTOR ), ENUM_ELEMENT ( SVC2_SETPLAYERVIEWHEIGHT ), diff -r 7fdf32e9c97e -r a423beb3f318 src/p_acs.cpp --- a/src/p_acs.cpp Wed Oct 28 12:06:27 2020 -0400 +++ b/src/p_acs.cpp Fri Oct 30 09:34:00 2020 -0400 @@ -4470,6 +4470,10 @@ case APROP_Species: actor->Species = FBehavior::StaticLookupString(value); + + // [AK] If we're the server, tell clients to update this actor property. + if ( NETWORK_GetState( ) == NETSTATE_SERVER ) + SERVERCOMMANDS_SetThingSpecies( actor ); break; case APROP_Score: diff -r 7fdf32e9c97e -r a423beb3f318 src/sv_commands.cpp --- a/src/sv_commands.cpp Wed Oct 28 12:06:27 2020 -0400 +++ b/src/sv_commands.cpp Fri Oct 30 09:34:00 2020 -0400 @@ -3643,6 +3643,19 @@ //***************************************************************************** // +void SERVERCOMMANDS_SetThingSpecies( AActor* mobj, ULONG ulPlayerExtra, ServerCommandFlags flags ) +{ + if ( !EnsureActorHasNetID (mobj) ) + return; + + NetCommand command( SVC2_SETTHINGSPECIES ); + command.addShort( mobj->lNetID ); + command.addString( mobj->Species ); + command.sendCommandToClients( ulPlayerExtra, flags ); +} + +//***************************************************************************** +// void SERVERCOMMANDS_UpdateThingScaleNotAtDefault( AActor* pActor, ULONG ulPlayerExtra, ServerCommandFlags flags ) { // [BB] Sanity check. diff -r 7fdf32e9c97e -r a423beb3f318 src/sv_commands.h --- a/src/sv_commands.h Wed Oct 28 12:06:27 2020 -0400 +++ b/src/sv_commands.h Fri Oct 30 09:34:00 2020 -0400 @@ -209,6 +209,7 @@ void SERVERCOMMANDS_SetFastChaseStrafeCount( AActor *mobj, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); void SERVERCOMMANDS_SetThingHealth( AActor* mobj, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); void SERVERCOMMANDS_SetThingScale( AActor* mobj, unsigned int scaleFlags, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); +void SERVERCOMMANDS_SetThingSpecies( AActor *mobj, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); void SERVERCOMMANDS_UpdateThingScaleNotAtDefault( AActor* pActor, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); void SERVERCOMMANDS_FlashStealthMonster( AActor* pActor, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); diff -r 7fdf32e9c97e -r a423beb3f318 src/sv_main.cpp --- a/src/sv_main.cpp Wed Oct 28 12:06:27 2020 -0400 +++ b/src/sv_main.cpp Fri Oct 30 09:34:00 2020 -0400 @@ -3379,6 +3379,10 @@ // [EP] Update the actor's scale if it's changed. SERVERCOMMANDS_UpdateThingScaleNotAtDefault ( pActor, ulClient, SVCF_ONLYTHISCLIENT ); + + // [AK] Update the actor's species if it's changed. + if ( strcmp( pActor->Species, pActor->GetDefault()->Species ) != 0 ) + SERVERCOMMANDS_SetThingSpecies( pActor, ulClient, SVCF_ONLYTHISCLIENT ); } //*****************************************************************************