Commit MetaInfo

Revisionaf9745b265ce8abb78e6d45a8483ff3ff52ae406 (tree)
Time2022-04-27 01:39:16
AuthorAdam Kaminski <kaminskiadam9@gmai...>
CommiterAdam Kaminski

Log Message

- Changed sv_respawndelaytime into a float. It's now possible to set respawn times that are below one second.
- The "ready to respawn in..." message now always appears if a player can respawn, which can be disabled with the CVar "r_drawrespawnstring".

Change Summary

Incremental Difference

diff -r 79730a158f1f -r af9745b265ce src/cl_main.cpp
--- a/src/cl_main.cpp Mon Apr 25 22:28:30 2022 -0400
+++ b/src/cl_main.cpp Tue Apr 26 12:39:16 2022 -0400
@@ -3969,15 +3969,18 @@
39693969 ClientObituary( players[ulPlayer].mo, pInflictor, NULL, MOD );
39703970 */
39713971
3972- // [AK] If we died, show how long we must wait before we can respawn if it's more than one second.
3972+ // [AK] If we died and can respawn, show how long we must wait before we can respawn.
39733973 if ( player - players == consoleplayer )
39743974 {
39753975 bool bNoMoreLivesLeft = ( GAMEMODE_AreLivesLimited( ) && GAMEMODE_IsGameInProgress( ) && ( player->ulLivesLeft == 0 ));
3976-
3977- if (( sv_respawndelaytime > 1 ) && ( player->mo->DamageType != NAME_SpawnTelefrag ) && ( bNoMoreLivesLeft == false ))
3978- HUD_SetRespawnTimeLeft( sv_respawndelaytime );
3979- else
3980- HUD_SetRespawnTimeLeft( -1 );
3976+ float fRespawnDelayTime = 1.0f;
3977+
3978+ if (( player->mo->DamageType != NAME_SpawnTelefrag ) && ( bNoMoreLivesLeft == false ))
3979+ fRespawnDelayTime = sv_respawndelaytime;
3980+
3981+ // [AK] The timer is precise to only one decimal place, so it's not worth showing
3982+ // the message if it's below 0.1 seconds.
3983+ HUD_SetRespawnTimeLeft(( bNoMoreLivesLeft == false && fRespawnDelayTime > 0.1f ) ? fRespawnDelayTime : -1.0f );
39813984 }
39823985
39833986 // Refresh the HUD, since this could affect the number of players left in an LMS game.
@@ -5904,8 +5907,8 @@
59045907 sv_allowprivatechat.ForceSet( Value, CVAR_Int );
59055908
59065909 // [AK] Read in, and set the value for sv_respawndelaytime.
5907- Value.Int = pByteStream->ReadByte();
5908- sv_respawndelaytime.ForceSet( Value, CVAR_Int );
5910+ Value.Float = pByteStream->ReadFloat();
5911+ sv_respawndelaytime.ForceSet( Value, CVAR_Float );
59095912 }
59105913
59115914 //*****************************************************************************
diff -r 79730a158f1f -r af9745b265ce src/g_shared/st_hud.cpp
--- a/src/g_shared/st_hud.cpp Mon Apr 25 22:28:30 2022 -0400
+++ b/src/g_shared/st_hud.cpp Tue Apr 26 12:39:16 2022 -0400
@@ -103,8 +103,8 @@
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;
106+// [AK] How long we have to wait until we can respawn, used for displaying on the screen.
107+static float g_fRespawnDelay = -1.0f;
108108
109109 // [AK] At what tic will we be able to respawn?
110110 static LONG g_lRespawnGametic = 0;
@@ -124,6 +124,7 @@
124124
125125 CVAR( Bool, cl_drawcoopinfo, true, CVAR_ARCHIVE )
126126 CVAR( Bool, r_drawspectatingstring, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG )
127+CVAR( Bool, r_drawrespawnstring, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG )
127128 EXTERN_CVAR( Int, con_notifylines )
128129 EXTERN_CVAR( Bool, cl_stfullscreenhud )
129130 EXTERN_CVAR( Int, screenblocks )
@@ -539,14 +540,14 @@
539540 }
540541
541542 // [AK] Show how much time is left before we can respawn if we had to wait for more than one second.
542- if (( players[consoleplayer].bSpectating == false ) && ( players[consoleplayer].playerstate == PST_DEAD ))
543+ if (( r_drawrespawnstring ) && ( players[consoleplayer].bSpectating == false ) && ( players[consoleplayer].playerstate == PST_DEAD ))
543544 {
544545 if ( g_lRespawnGametic > level.time )
545546 {
546- ULONG ulTimeLeft = MIN( g_lRespawnDelay, 1 + ( g_lRespawnGametic - level.time ) / TICRATE );
547+ float fTimeLeft = MIN( g_fRespawnDelay, static_cast<float>( g_lRespawnGametic - level.time ) / TICRATE );
547548
548549 bottomString += "\n" TEXTCOLOR_GREEN;
549- bottomString.AppendFormat( "Ready to respawn in %lu second%s", ulTimeLeft, ulTimeLeft != 1 ? "s" : "" );
550+ bottomString.AppendFormat( "Ready to respawn in %.1f seconds", fTimeLeft );
550551 }
551552 }
552553
@@ -1057,14 +1058,14 @@
10571058
10581059 //*****************************************************************************
10591060 //
1060-void HUD_SetRespawnTimeLeft( LONG lRespawnTime )
1061+void HUD_SetRespawnTimeLeft( float fRespawnTime )
10611062 {
10621063 // [AK] The server shouldn't execute this.
10631064 if ( NETWORK_GetState( ) == NETSTATE_SERVER )
10641065 return;
10651066
1066- g_lRespawnDelay = lRespawnTime;
1067- g_lRespawnGametic = level.time + g_lRespawnDelay * TICRATE;
1067+ g_fRespawnDelay = fRespawnTime;
1068+ g_lRespawnGametic = level.time + static_cast<LONG>( g_fRespawnDelay * TICRATE );
10681069 }
10691070
10701071 //*****************************************************************************
diff -r 79730a158f1f -r af9745b265ce src/g_shared/st_hud.h
--- a/src/g_shared/st_hud.h Mon Apr 25 22:28:30 2022 -0400
+++ b/src/g_shared/st_hud.h Tue Apr 26 12:39:16 2022 -0400
@@ -86,7 +86,7 @@
8686 ULONG HUD_GetNumSpectators( void );
8787 ULONG HUD_GetRank( void );
8888 LONG HUD_GetSpread( void );
89-void HUD_SetRespawnTimeLeft( LONG lRespawnTime );
89+void HUD_SetRespawnTimeLeft( float fRespawnTime );
9090 FString HUD_SpellOrdinal( int ranknum, bool bColored = false );
9191 FString HUD_BuildPointString( void );
9292 FString HUD_BuildPlaceString( ULONG ulPlayer );
diff -r 79730a158f1f -r af9745b265ce src/p_interaction.cpp
--- a/src/p_interaction.cpp Mon Apr 25 22:28:30 2022 -0400
+++ b/src/p_interaction.cpp Tue Apr 26 12:39:16 2022 -0400
@@ -725,25 +725,24 @@
725725 if ((( zacompatflags & ZACOMPATF_INSTANTRESPAWN ) == false ) ||
726726 ( player->bSpawnTelefragged ) || ( bNoMoreLivesLeft ))
727727 {
728- // [AK] The respawn delay can be adjusted, but the minimum is one second. This only works if
729- // the player wasn't spawn telefragged and still has lives left.
730- if (( sv_respawndelaytime > 1 ) && ( player->bSpawnTelefragged == false ) && ( bNoMoreLivesLeft == false ))
728+ float fRespawnDelayTime = 1.0f;
729+
730+ // [AK] The respawn delay can be adjusted if the player wasn't spawn telefragged and still has lives left.
731+ if (( player->bSpawnTelefragged == false ) && ( bNoMoreLivesLeft == false ))
731732 {
732- player->respawn_time = level.time + sv_respawndelaytime * TICRATE;
733-
734- // [AK] Show how long we must wait until we can respawn on the screen.
735- if ( player - players == consoleplayer )
736- HUD_SetRespawnTimeLeft( sv_respawndelaytime );
733+ player->respawn_time = level.time + static_cast<int>( sv_respawndelaytime * TICRATE );
734+ fRespawnDelayTime = sv_respawndelaytime;
737735 }
738736 else
739737 {
740738 player->respawn_time = level.time + TICRATE;
741-
742- // [AK] We don't need to show how long to wait before we can respawn here.
743- if ( player - players == consoleplayer )
744- HUD_SetRespawnTimeLeft( -1 );
745739 }
746740
741+ // [AK] Show how long we must wait until we can respawn on the screen. The timer is precise to
742+ // only one decimal place, so it's not worth showing if it's below 0.1 seconds.
743+ if ( player - players == consoleplayer )
744+ HUD_SetRespawnTimeLeft(( bNoMoreLivesLeft == false && fRespawnDelayTime > 0.1f ) ? fRespawnDelayTime : -1.0f );
745+
747746 // [BC] Don't respawn quite so fast on forced respawn. It sounds weird when your
748747 // scream isn't completed.
749748 // [RK] We can add on a custom force respawn delay instead drawn from the forcerespawn time CVAR
diff -r 79730a158f1f -r af9745b265ce src/sv_commands.cpp
--- a/src/sv_commands.cpp Mon Apr 25 22:28:30 2022 -0400
+++ b/src/sv_commands.cpp Tue Apr 26 12:39:16 2022 -0400
@@ -2352,7 +2352,7 @@
23522352 // [AK] Send sv_allowprivatechat.
23532353 command.addByte( sv_allowprivatechat );
23542354 // [AK] Send sv_respawndelaytime.
2355- command.addByte( sv_respawndelaytime );
2355+ command.addFloat( sv_respawndelaytime );
23562356 command.sendCommandToClients( ulPlayerExtra, flags );
23572357 }
23582358
diff -r 79730a158f1f -r af9745b265ce src/sv_main.cpp
--- a/src/sv_main.cpp Mon Apr 25 22:28:30 2022 -0400
+++ b/src/sv_main.cpp Tue Apr 26 12:39:16 2022 -0400
@@ -457,23 +457,19 @@
457457
458458 //*****************************************************************************
459459 //
460-CUSTOM_CVAR( Int, sv_respawndelaytime, 1, CVAR_ARCHIVE | CVAR_SERVERINFO )
461-{
462- if ( self < 1 )
463- {
464- self = 1;
465- return;
466- }
467- else if ( self > 255 )
468- {
469- self = 255;
460+CUSTOM_CVAR( Float, sv_respawndelaytime, 1.0f, CVAR_ARCHIVE | CVAR_SERVERINFO )
461+{
462+ // [AK] The respawn delay time should always be at least a tic long.
463+ if ( self <= 0.0f )
464+ {
465+ self = 1.0f / TICRATE;
470466 return;
471467 }
472468
473469 // [AK] Notify the clients about the change.
474470 if (( NETWORK_GetState( ) == NETSTATE_SERVER ) && ( gamestate != GS_STARTUP ))
475471 {
476- SERVER_Printf( "%s changed to: %d\n", self.GetName( ), self.GetGenericRep( CVAR_Int ).Int );
472+ SERVER_Printf( "%s changed to: %.1f\n", self.GetName( ), static_cast<float>( self ));
477473 SERVERCOMMANDS_SetGameModeLimits( );
478474 }
479475 }
diff -r 79730a158f1f -r af9745b265ce src/sv_main.h
--- a/src/sv_main.h Mon Apr 25 22:28:30 2022 -0400
+++ b/src/sv_main.h Tue Apr 26 12:39:16 2022 -0400
@@ -694,7 +694,7 @@
694694 EXTERN_CVAR( Bool, sv_forcepassword );
695695 EXTERN_CVAR( Bool, sv_forcejoinpassword );
696696 EXTERN_CVAR( Int, sv_forcerespawntime ); // [RK] Delay used for forced respawn
697-EXTERN_CVAR( Int, sv_respawndelaytime );
697+EXTERN_CVAR( Float, sv_respawndelaytime );
698698 EXTERN_CVAR( Bool, sv_showlauncherqueries );
699699 EXTERN_CVAR( Int, sv_maxclients );
700700 EXTERN_CVAR( Int, sv_maxplayers );
Show on old repository browser