Commit MetaInfo

Revision9ebf9fc0d00992b4eca9ed54d51b1cf74467f6a7 (tree)
Time2022-04-24 09:19:52
AuthorAdam Kaminski <kaminskiadam9@gmai...>
CommiterAdam Kaminski

Log Message

Fixed: Player.DamageScreenColor didn't work properly in online games if it used a specific damage type.

Change Summary

Incremental Difference

diff -r af9745b265ce -r 9ebf9fc0d009 protocolspec/spec.players.txt
--- a/protocolspec/spec.players.txt Tue Apr 26 12:39:16 2022 -0400
+++ b/protocolspec/spec.players.txt Sat Apr 23 20:19:52 2022 -0400
@@ -59,6 +59,15 @@
5959 Actor attacker with NullAllowed
6060 EndCommand
6161
62+Command DamagePlayerWithType
63+ ExtendedCommand
64+ Player player with MoTest
65+ Variable health
66+ Variable armor
67+ String damageType
68+ Actor attacker with NullAllowed
69+EndCommand
70+
6271 Command KillPlayer
6372 Player player with MoTest
6473 Actor source with NullAllowed
diff -r af9745b265ce -r 9ebf9fc0d009 src/cl_main.cpp
--- a/src/cl_main.cpp Tue Apr 26 12:39:16 2022 -0400
+++ b/src/cl_main.cpp Sat Apr 23 20:19:52 2022 -0400
@@ -3837,7 +3837,7 @@
38373837
38383838 //*****************************************************************************
38393839 //
3840-void ServerCommands::DamagePlayer::Execute()
3840+static void client_DamagePlayer( player_t *player, int health, int armor, AActor *attacker )
38413841 {
38423842 // Level not loaded, ignore...
38433843 if ( gamestate != GS_LEVEL )
@@ -3883,6 +3883,26 @@
38833883
38843884 //*****************************************************************************
38853885 //
3886+void ServerCommands::DamagePlayer::Execute()
3887+{
3888+ // [AK] No damage type was sent to us, revert the player's DamageTypeReceived to "none".
3889+ player->mo->DamageTypeReceived = "None";
3890+
3891+ client_DamagePlayer( player, health, armor, attacker );
3892+}
3893+
3894+//*****************************************************************************
3895+//
3896+void ServerCommands::DamagePlayerWithType::Execute()
3897+{
3898+ // [AK] Set the player's DamageTypeReceived to whatever was sent to us.
3899+ player->mo->DamageTypeReceived = damageType;
3900+
3901+ client_DamagePlayer( player, health, armor, attacker );
3902+}
3903+
3904+//*****************************************************************************
3905+//
38863906 void ServerCommands::KillPlayer::Execute()
38873907 {
38883908 // Set the player's new health.
diff -r af9745b265ce -r 9ebf9fc0d009 src/network_enums.h
--- a/src/network_enums.h Tue Apr 26 12:39:16 2022 -0400
+++ b/src/network_enums.h Sat Apr 23 20:19:52 2022 -0400
@@ -371,6 +371,7 @@
371371 ENUM_ELEMENT ( SVC2_SYNCMAPROTATION ),
372372 ENUM_ELEMENT ( SVC2_UPDATEMAPROTATION ),
373373 ENUM_ELEMENT ( SVC2_STOPALLSOUNDSONTHING ),
374+ ENUM_ELEMENT ( SVC2_DAMAGEPLAYERWITHTYPE ),
374375 // [BB] Commands necessary for the account system.
375376 ENUM_ELEMENT ( SVC2_SRP_USER_START_AUTHENTICATION ),
376377 ENUM_ELEMENT ( SVC2_SRP_USER_PROCESS_CHALLENGE ),
diff -r af9745b265ce -r 9ebf9fc0d009 src/sv_commands.cpp
--- a/src/sv_commands.cpp Tue Apr 26 12:39:16 2022 -0400
+++ b/src/sv_commands.cpp Sat Apr 23 20:19:52 2022 -0400
@@ -347,6 +347,8 @@
347347 {
348348 ULONG ulArmorPoints;
349349 AInventory *pArmor;
350+ PalEntry painFlash;
351+ bool bSendDamageType = false;
350352
351353 if ( PLAYER_IsValidPlayer( ulPlayer ) == false )
352354 return;
@@ -361,6 +363,12 @@
361363
362364 // If the player doesn't possess any armor, then his armor points are 0.
363365 ulArmorPoints = ( pArmor != NULL ) ? pArmor->Amount : 0;
366+
367+ // [AK] Check if the player's class has a special pain flash for the damage type they just
368+ // received. If it does, then we'll also send the damage type under a different command so
369+ // that the pain flash appears properly on the client's screen.
370+ if ( players[ulPlayer].mo->GetClass( )->ActorInfo->GetPainFlash( players[ulPlayer].mo->DamageTypeReceived, &painFlash ))
371+ bSendDamageType = true;
364372 }
365373
366374 ServerCommands::DamagePlayer fullCommand;
@@ -374,12 +382,33 @@
374382 // [EP] Send the updated health and armor of the player who's being damaged to this client
375383 // only if this client is allowed to know.
376384 if ( SERVER_IsPlayerAllowedToKnowHealth( *it, ulPlayer ))
377- fullCommand.sendCommandToClients( *it, SVCF_ONLYTHISCLIENT );
385+ {
386+ // [AK] If we're going to send the damage type, make sure that this client is watching the
387+ // player. Otherwise, they don't need to know the damage type.
388+ if (( bSendDamageType ) && ( SERVER_GetClient( *it )->ulDisplayPlayer == ulPlayer ))
389+ SERVERCOMMANDS_DamagePlayerWithType( ulPlayer, ulArmorPoints, *it );
390+ else
391+ fullCommand.sendCommandToClients( *it, SVCF_ONLYTHISCLIENT );
392+ }
378393 }
379394 }
380395
381396 //*****************************************************************************
382397 //
398+void SERVERCOMMANDS_DamagePlayerWithType( ULONG ulPlayer, ULONG ulArmorPoints, ULONG ulPlayerExtra )
399+{
400+ ServerCommands::DamagePlayerWithType command;
401+ command.SetPlayer( &players[ulPlayer] );
402+ command.SetHealth( players[ulPlayer].health );
403+ command.SetArmor( ulArmorPoints );
404+ command.SetDamageType( players[ulPlayer].mo->DamageTypeReceived.GetChars() );
405+ command.SetAttacker( players[ulPlayer].attacker );
406+
407+ command.sendCommandToClients( ulPlayerExtra, SVCF_ONLYTHISCLIENT );
408+}
409+
410+//*****************************************************************************
411+//
383412 void SERVERCOMMANDS_KillPlayer( ULONG ulPlayer, AActor *pSource, AActor *pInflictor, FName MOD )
384413 {
385414 if ( PLAYER_IsValidPlayer( ulPlayer ) == false )
diff -r af9745b265ce -r 9ebf9fc0d009 src/sv_commands.h
--- a/src/sv_commands.h Tue Apr 26 12:39:16 2022 -0400
+++ b/src/sv_commands.h Sat Apr 23 20:19:52 2022 -0400
@@ -91,6 +91,7 @@
9191 void SERVERCOMMANDS_SpawnPlayer( ULONG ulPlayer, LONG lPlayerState, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0, bool bMorph = false );
9292 void SERVERCOMMANDS_MovePlayer( ULONG ulPlayer, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 );
9393 void SERVERCOMMANDS_DamagePlayer( ULONG ulPlayer );
94+void SERVERCOMMANDS_DamagePlayerWithType( ULONG ulPlayer, ULONG ulArmorPoints, ULONG ulPlayerExtra );
9495 void SERVERCOMMANDS_KillPlayer( ULONG ulPlayer, AActor *pSource, AActor *pInflictor, FName MOD );
9596 void SERVERCOMMANDS_SetPlayerHealth( ULONG ulPlayer, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 );
9697 void SERVERCOMMANDS_SetPlayerArmor( ULONG ulPlayer, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 );
Show on old repository browser