Commit MetaInfo

Revisiona944a53944a8847d860297992c9edd909092c881 (tree)
Time2021-11-22 04:41:20
AuthorAdam Kaminski <kaminskiadam9@gmai...>
CommiterAdam Kaminski

Log Message

Show how long a player must wait before respawning on the bottom of the screen if sv_respawndelaytime is greater than 1.

Change Summary

Incremental Difference

diff -r 0fa647e1dc71 -r a944a53944a8 src/cl_main.cpp
--- a/src/cl_main.cpp Sun Nov 21 17:33:34 2021 +0100
+++ b/src/cl_main.cpp Sun Nov 21 14:41:20 2021 -0500
@@ -3980,6 +3980,17 @@
39803980 ClientObituary( players[ulPlayer].mo, pInflictor, NULL, MOD );
39813981 */
39823982
3983+ // [AK] If we died, show how long we must wait before we can respawn if it's more than one second.
3984+ if ( player - players == consoleplayer )
3985+ {
3986+ bool bNoMoreLivesLeft = ( GAMEMODE_AreLivesLimited( ) && GAMEMODE_IsGameInProgress( ) && ( player->ulLivesLeft == 0 ));
3987+
3988+ if (( sv_respawndelaytime > 1 ) && ( player->mo->DamageType != NAME_SpawnTelefrag ) && ( bNoMoreLivesLeft == false ))
3989+ HUD_SetRespawnTimeLeft( sv_respawndelaytime );
3990+ else
3991+ HUD_SetRespawnTimeLeft( -1 );
3992+ }
3993+
39833994 // Refresh the HUD, since this could affect the number of players left in an LMS game.
39843995 HUD_Refresh( );
39853996 }
@@ -5902,6 +5913,10 @@
59025913 // [AK] Read in, and set the value for sv_allowprivatechat.
59035914 Value.Int = pByteStream->ReadByte();
59045915 sv_allowprivatechat.ForceSet( Value, CVAR_Int );
5916+
5917+ // [AK] Read in, and set the value for sv_respawndelaytime.
5918+ Value.Int = pByteStream->ReadByte();
5919+ sv_respawndelaytime.ForceSet( Value, CVAR_Int );
59055920 }
59065921
59075922 //*****************************************************************************
diff -r 0fa647e1dc71 -r a944a53944a8 src/g_shared/st_hud.cpp
--- a/src/g_shared/st_hud.cpp Sun Nov 21 17:33:34 2021 +0100
+++ b/src/g_shared/st_hud.cpp Sun Nov 21 14:41:20 2021 -0500
@@ -103,6 +103,12 @@
103103 // [AK] Who are the two duelers?
104104 static player_t *g_pDuelers[2];
105105
106+// [AK] How long we have to wait until we can respawn, used for displaying on the screen if sv_respawndelaytime is greater than 1.
107+static LONG g_lRespawnDelay = -1;
108+
109+// [AK] At what tic will we be able to respawn?
110+static LONG g_lRespawnGametic = 0;
111+
106112 //*****************************************************************************
107113 // PROTOTYPES
108114
@@ -529,6 +535,18 @@
529535 }
530536 }
531537
538+ // [AK] Show how much time is left before we can respawn if we had to wait for more than one second.
539+ if (( players[consoleplayer].bSpectating == false ) && ( players[consoleplayer].playerstate == PST_DEAD ))
540+ {
541+ if ( g_lRespawnGametic > level.time )
542+ {
543+ ULONG ulTimeLeft = MIN( g_lRespawnDelay, 1 + ( g_lRespawnGametic - level.time ) / TICRATE );
544+
545+ bottomString += "\n" TEXTCOLOR_GREEN;
546+ bottomString.AppendFormat( "Ready to respawn in %d second%s", ulTimeLeft, ulTimeLeft != 1 ? "s" : "" );
547+ }
548+ }
549+
532550 // If the console player is spectating, draw the spectator message.
533551 // [BB] Only when not in free spectate mode.
534552 if (( r_drawspectatingstring ) && ( players[consoleplayer].bSpectating ) && ( CLIENTDEMO_IsInFreeSpectateMode( ) == false ))
@@ -953,6 +971,18 @@
953971
954972 //*****************************************************************************
955973 //
974+void HUD_SetRespawnTimeLeft( LONG lRespawnTime )
975+{
976+ // [AK] The server shouldn't execute this.
977+ if ( NETWORK_GetState( ) == NETSTATE_SERVER )
978+ return;
979+
980+ g_lRespawnDelay = lRespawnTime;
981+ g_lRespawnGametic = level.time + g_lRespawnDelay * TICRATE;
982+}
983+
984+//*****************************************************************************
985+//
956986 // [TP] Now in a function
957987 //
958988 FString HUD_SpellOrdinal( int ranknum, bool bColored )
diff -r 0fa647e1dc71 -r a944a53944a8 src/g_shared/st_hud.h
--- a/src/g_shared/st_hud.h Sun Nov 21 17:33:34 2021 +0100
+++ b/src/g_shared/st_hud.h Sun Nov 21 14:41:20 2021 -0500
@@ -82,6 +82,7 @@
8282 ULONG HUD_GetNumSpectators( void );
8383 ULONG HUD_GetRank( void );
8484 LONG HUD_GetSpread( void );
85+void HUD_SetRespawnTimeLeft( LONG lRespawnTime );
8586 FString HUD_SpellOrdinal( int ranknum, bool bColored = false );
8687 FString HUD_BuildPointString( void );
8788 FString HUD_BuildPlaceString( ULONG ulPlayer );
diff -r 0fa647e1dc71 -r a944a53944a8 src/p_interaction.cpp
--- a/src/p_interaction.cpp Sun Nov 21 17:33:34 2021 +0100
+++ b/src/p_interaction.cpp Sun Nov 21 14:41:20 2021 -0500
@@ -758,9 +758,21 @@
758758 // [AK] The respawn delay can be adjusted, but the minimum is one second. This only works if
759759 // the player wasn't spawn telefragged and still has lives left.
760760 if (( sv_respawndelaytime > 1 ) && ( player->bSpawnTelefragged == false ) && ( bNoMoreLivesLeft == false ))
761+ {
761762 player->respawn_time = level.time + sv_respawndelaytime * TICRATE;
763+
764+ // [AK] Show how long we must wait until we can respawn on the screen.
765+ if ( player - players == consoleplayer )
766+ HUD_SetRespawnTimeLeft( sv_respawndelaytime );
767+ }
762768 else
769+ {
763770 player->respawn_time = level.time + TICRATE;
771+
772+ // [AK] We don't need to show how long to wait before we can respawn here.
773+ if ( player - players == consoleplayer )
774+ HUD_SetRespawnTimeLeft( -1 );
775+ }
764776
765777 // [BC] Don't respawn quite so fast on forced respawn. It sounds weird when your
766778 // scream isn't completed.
diff -r 0fa647e1dc71 -r a944a53944a8 src/sv_commands.cpp
--- a/src/sv_commands.cpp Sun Nov 21 17:33:34 2021 +0100
+++ b/src/sv_commands.cpp Sun Nov 21 14:41:20 2021 -0500
@@ -2336,6 +2336,8 @@
23362336 command.addByte( sv_limitcommands );
23372337 // [AK] Send sv_allowprivatechat.
23382338 command.addByte( sv_allowprivatechat );
2339+ // [AK] Send sv_respawndelaytime.
2340+ command.addByte( sv_respawndelaytime );
23392341 command.sendCommandToClients( ulPlayerExtra, flags );
23402342 }
23412343
diff -r 0fa647e1dc71 -r a944a53944a8 src/sv_main.cpp
--- a/src/sv_main.cpp Sun Nov 21 17:33:34 2021 +0100
+++ b/src/sv_main.cpp Sun Nov 21 14:41:20 2021 -0500
@@ -267,7 +267,6 @@
267267 CVAR( Bool, sv_forcepassword, false, CVAR_ARCHIVE|CVAR_NOSETBYACS|CVAR_SERVERINFO )
268268 CVAR( Bool, sv_forcejoinpassword, false, CVAR_ARCHIVE|CVAR_NOSETBYACS|CVAR_SERVERINFO )
269269 CVAR( Int, sv_forcerespawntime, 0, CVAR_ARCHIVE|CVAR_SERVERINFO ) // [RK]
270-CVAR( Int, sv_respawndelaytime, 1, CVAR_ARCHIVE|CVAR_SERVERINFO ) // [AK]
271270 CVAR( Bool, sv_showlauncherqueries, false, CVAR_ARCHIVE )
272271 CVAR( Bool, sv_timestamp, false, CVAR_ARCHIVE|CVAR_NOSETBYACS )
273272 CVAR( Int, sv_timestampformat, 0, CVAR_ARCHIVE|CVAR_NOSETBYACS )
@@ -456,6 +455,29 @@
456455 }
457456
458457 //*****************************************************************************
458+//
459+CUSTOM_CVAR( Int, sv_respawndelaytime, 1, CVAR_ARCHIVE | CVAR_SERVERINFO )
460+{
461+ if ( self < 1 )
462+ {
463+ self = 1;
464+ return;
465+ }
466+ else if ( self > 255 )
467+ {
468+ self = 255;
469+ return;
470+ }
471+
472+ // [AK] Notify the clients about the change.
473+ if (( NETWORK_GetState( ) == NETSTATE_SERVER ) && ( gamestate != GS_STARTUP ))
474+ {
475+ SERVER_Printf( "%s changed to: %d\n", self.GetName( ), self.GetGenericRep( CVAR_Int ).Int );
476+ SERVERCOMMANDS_SetGameModeLimits( );
477+ }
478+}
479+
480+//*****************************************************************************
459481 // FUNCTIONS
460482
461483 void SERVER_Construct( void )
Show on old repository browser