# HG changeset patch # User Adam Kaminski # Date 1632067832 14400 # Sun Sep 19 12:10:32 2021 -0400 # Node ID 7797d4cbadc3314e40c0a20d85b341ef8040ff75 # Parent d96804bbb07a379df6e77b7136a09c56761f4b63 Replaced the server command "SetThingSpecies" with "SetThingStringProperty", which also tells clients to update an actor's name tag if it's changed. diff -r d96804bbb07a -r 7797d4cbadc3 protocolspec/spec.things.txt --- a/protocolspec/spec.things.txt Sat Sep 18 21:15:56 2021 -0400 +++ b/protocolspec/spec.things.txt Sun Sep 19 12:10:32 2021 -0400 @@ -214,6 +214,13 @@ Long value EndCommand +Command SetThingStringProperty + ExtendedCommand + Actor actor + Byte property + String value +EndCommand + Command SetThingSound Actor actor Byte soundType @@ -290,12 +297,6 @@ 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 d96804bbb07a -r 7797d4cbadc3 src/cl_main.cpp --- a/src/cl_main.cpp Sat Sep 18 21:15:56 2021 -0400 +++ b/src/cl_main.cpp Sun Sep 19 12:10:32 2021 -0400 @@ -5296,6 +5296,27 @@ //***************************************************************************** // +void ServerCommands::SetThingStringProperty::Execute() +{ + // Set one of the actor's properties, depending on what was read in. + switch ( property ) + { + case APROP_Species: + actor->Species = value; + break; + + case APROP_NameTag: + actor->SetTag( value ); + break; + + default: + CLIENT_PrintWarning( "client_SetThingStringProperty: Unknown property, %d!\n", static_cast (property) ); + return; + } +} + +//***************************************************************************** +// void ServerCommands::SetThingSound::Execute() { // Set one of the actor's sounds, depending on what was read in. @@ -5456,13 +5477,6 @@ //***************************************************************************** // -void ServerCommands::SetThingSpecies::Execute() -{ - actor->Species = species; -} - -//***************************************************************************** -// void ServerCommands::SetWeaponAmmoGive::Execute() { weapon->AmmoGive1 = ammoGive1; diff -r d96804bbb07a -r 7797d4cbadc3 src/network_enums.h --- a/src/network_enums.h Sat Sep 18 21:15:56 2021 -0400 +++ b/src/network_enums.h Sun Sep 19 12:10:32 2021 -0400 @@ -349,7 +349,7 @@ ENUM_ELEMENT ( SVC2_BUILDSTAIR ), ENUM_ELEMENT ( SVC2_SETMUGSHOTSTATE ), ENUM_ELEMENT ( SVC2_SETTHINGSCALE ), - ENUM_ELEMENT ( SVC2_SETTHINGSPECIES ), + ENUM_ELEMENT ( SVC2_SETTHINGSTRINGPROPERTY ), ENUM_ELEMENT ( SVC2_SETMAPNUMTOTALSECRETS ), ENUM_ELEMENT ( SVC2_SOUNDSECTOR ), ENUM_ELEMENT ( SVC2_SETPLAYERVIEWHEIGHT ), diff -r d96804bbb07a -r 7797d4cbadc3 src/p_acs.cpp --- a/src/p_acs.cpp Sat Sep 18 21:15:56 2021 -0400 +++ b/src/p_acs.cpp Sun Sep 19 12:10:32 2021 -0400 @@ -4409,6 +4409,7 @@ // [BB] int oldValue = 0; FRenderStyle oldRenderStyle; + const char *oldString; switch (property) { @@ -4654,14 +4655,14 @@ case APROP_Species: // [AK] Save the original species. - oldValue = actor->Species; + oldString = actor->Species; actor->Species = FBehavior::StaticLookupString(value); // [AK] If we're the server, tell clients to update this actor property. // Only bother the clients if the species has actually changed. - if ( ( NETWORK_GetState( ) == NETSTATE_SERVER ) && ( oldValue != actor->Species ) ) - SERVERCOMMANDS_SetThingSpecies( actor ); + if ( ( NETWORK_GetState( ) == NETSTATE_SERVER ) && ( strcmp( actor->GetSpecies( ), oldString ) != 0 ) ) + SERVERCOMMANDS_SetThingStringProperty( actor, APROP_Species ); break; case APROP_Score: @@ -4669,7 +4670,15 @@ break; case APROP_NameTag: + // [AK] Save the original name tag. + oldString = actor->GetTag( ); + actor->SetTag(FBehavior::StaticLookupString(value)); + + // [AK] If we're the server, tell clients to update this actor property. + // Only bother the clients if the name tag has actually changed. + if ( ( NETWORK_GetState( ) == NETSTATE_SERVER ) && ( strcmp( actor->GetTag( ), oldString ) != 0 ) ) + SERVERCOMMANDS_SetThingStringProperty( actor, APROP_NameTag ); break; case APROP_DamageFactor: diff -r d96804bbb07a -r 7797d4cbadc3 src/sv_commands.cpp --- a/src/sv_commands.cpp Sat Sep 18 21:15:56 2021 -0400 +++ b/src/sv_commands.cpp Sun Sep 19 12:10:32 2021 -0400 @@ -1681,6 +1681,37 @@ //***************************************************************************** // +void SERVERCOMMANDS_SetThingStringProperty( AActor *pActor, ULONG ulProperty, ULONG ulPlayerExtra, ServerCommandFlags flags ) +{ + if ( !EnsureActorHasNetID (pActor) ) + return; + + const char *value; + + // Set one of the actor's properties, depending on what was read in. + switch ( ulProperty ) + { + case APROP_Species: + value = pActor->GetSpecies( ); + break; + + case APROP_NameTag: + value = pActor->GetTag( ); + break; + + default: + return; + } + + ServerCommands::SetThingStringProperty command; + command.SetActor( pActor ); + command.SetProperty( ulProperty ); + command.SetValue( value ); + command.sendCommandToClients( ulPlayerExtra, flags ); +} + +//***************************************************************************** +// void SERVERCOMMANDS_SetThingSound( AActor *pActor, ULONG ulSound, const char *pszSound, ULONG ulPlayerExtra, ServerCommandFlags flags ) { if ( !EnsureActorHasNetID (pActor) ) @@ -3875,19 +3906,6 @@ //***************************************************************************** // -void SERVERCOMMANDS_SetThingSpecies( AActor* mobj, ULONG ulPlayerExtra, ServerCommandFlags flags ) -{ - if ( !EnsureActorHasNetID (mobj) ) - return; - - NetCommand command( SVC2_SETTHINGSPECIES ); - command.addShort( mobj->NetID ); - command.addString( mobj->Species ); - command.sendCommandToClients( ulPlayerExtra, flags ); -} - -//***************************************************************************** -// void SERVERCOMMANDS_UpdateThingScaleNotAtDefault( AActor* pActor, ULONG ulPlayerExtra, ServerCommandFlags flags ) { // [BB] Sanity check. diff -r d96804bbb07a -r 7797d4cbadc3 src/sv_commands.h --- a/src/sv_commands.h Sat Sep 18 21:15:56 2021 -0400 +++ b/src/sv_commands.h Sun Sep 19 12:10:32 2021 -0400 @@ -162,6 +162,7 @@ void SERVERCOMMANDS_SetThingArguments( AActor *pActor, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); void SERVERCOMMANDS_SetThingTranslation( AActor *pActor, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); void SERVERCOMMANDS_SetThingProperty( AActor *pActor, ULONG ulProperty, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); +void SERVERCOMMANDS_SetThingStringProperty( AActor *pActor, ULONG ulProperty, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); void SERVERCOMMANDS_SetThingSound( AActor *pActor, ULONG ulSound, const char *pszSound, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); void SERVERCOMMANDS_SetThingSpawnPoint( AActor *pActor, ULONG ulPlayerExtra, ServerCommandFlags flags ); void SERVERCOMMANDS_SetThingSpecial( AActor *pActor, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); @@ -188,7 +189,6 @@ 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 ); void SERVERCOMMANDS_StopAllSoundsOnThing( AActor* pActor, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); diff -r d96804bbb07a -r 7797d4cbadc3 src/sv_main.cpp --- a/src/sv_main.cpp Sat Sep 18 21:15:56 2021 -0400 +++ b/src/sv_main.cpp Sun Sep 19 12:10:32 2021 -0400 @@ -3459,6 +3459,14 @@ && static_cast( pActor )->JumpZ != static_cast( pActor->GetDefault( ) )->JumpZ ) SERVERCOMMANDS_SetThingProperty( pActor, APROP_JumpZ, ulClient, SVCF_ONLYTHISCLIENT ); + // [AK] Update the actor's species if it's changed. + if ( strcmp( pActor->Species, pActor->GetDefault()->Species ) != 0 ) + SERVERCOMMANDS_SetThingStringProperty( pActor, APROP_Species, ulClient, SVCF_ONLYTHISCLIENT ); + + // [AK] Update the actor's name tag if it's changed. + if (( pActor->Tag != NULL ) && (( pActor->GetDefault()->Tag == NULL ) || ( pActor->Tag->Compare( *pActor->GetDefault()->Tag ) != 0 ))) + SERVERCOMMANDS_SetThingStringProperty( pActor, APROP_NameTag, ulClient, SVCF_ONLYTHISCLIENT ); + // [BB] Update the actor's gravity if it's changed. if ( pActor->gravity != pActor->GetDefault( )->gravity ) SERVERCOMMANDS_SetThingGravity ( pActor, ulClient, SVCF_ONLYTHISCLIENT ); @@ -3489,10 +3497,6 @@ // [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 ); } //*****************************************************************************