Revision | af9745b265ce8abb78e6d45a8483ff3ff52ae406 (tree) |
---|---|
Time | 2022-04-27 01:39:16 |
Author | Adam Kaminski <kaminskiadam9@gmai...> |
Commiter | Adam Kaminski |
- 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".
@@ -3969,15 +3969,18 @@ | ||
3969 | 3969 | ClientObituary( players[ulPlayer].mo, pInflictor, NULL, MOD ); |
3970 | 3970 | */ |
3971 | 3971 | |
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. | |
3973 | 3973 | if ( player - players == consoleplayer ) |
3974 | 3974 | { |
3975 | 3975 | 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 ); | |
3981 | 3984 | } |
3982 | 3985 | |
3983 | 3986 | // Refresh the HUD, since this could affect the number of players left in an LMS game. |
@@ -5904,8 +5907,8 @@ | ||
5904 | 5907 | sv_allowprivatechat.ForceSet( Value, CVAR_Int ); |
5905 | 5908 | |
5906 | 5909 | // [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 ); | |
5909 | 5912 | } |
5910 | 5913 | |
5911 | 5914 | //***************************************************************************** |
@@ -103,8 +103,8 @@ | ||
103 | 103 | // [AK] Who are the two duelers? |
104 | 104 | static player_t *g_pDuelers[2]; |
105 | 105 | |
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; | |
108 | 108 | |
109 | 109 | // [AK] At what tic will we be able to respawn? |
110 | 110 | static LONG g_lRespawnGametic = 0; |
@@ -124,6 +124,7 @@ | ||
124 | 124 | |
125 | 125 | CVAR( Bool, cl_drawcoopinfo, true, CVAR_ARCHIVE ) |
126 | 126 | CVAR( Bool, r_drawspectatingstring, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG ) |
127 | +CVAR( Bool, r_drawrespawnstring, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG ) | |
127 | 128 | EXTERN_CVAR( Int, con_notifylines ) |
128 | 129 | EXTERN_CVAR( Bool, cl_stfullscreenhud ) |
129 | 130 | EXTERN_CVAR( Int, screenblocks ) |
@@ -539,14 +540,14 @@ | ||
539 | 540 | } |
540 | 541 | |
541 | 542 | // [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 )) | |
543 | 544 | { |
544 | 545 | if ( g_lRespawnGametic > level.time ) |
545 | 546 | { |
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 ); | |
547 | 548 | |
548 | 549 | 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 ); | |
550 | 551 | } |
551 | 552 | } |
552 | 553 |
@@ -1057,14 +1058,14 @@ | ||
1057 | 1058 | |
1058 | 1059 | //***************************************************************************** |
1059 | 1060 | // |
1060 | -void HUD_SetRespawnTimeLeft( LONG lRespawnTime ) | |
1061 | +void HUD_SetRespawnTimeLeft( float fRespawnTime ) | |
1061 | 1062 | { |
1062 | 1063 | // [AK] The server shouldn't execute this. |
1063 | 1064 | if ( NETWORK_GetState( ) == NETSTATE_SERVER ) |
1064 | 1065 | return; |
1065 | 1066 | |
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 ); | |
1068 | 1069 | } |
1069 | 1070 | |
1070 | 1071 | //***************************************************************************** |
@@ -86,7 +86,7 @@ | ||
86 | 86 | ULONG HUD_GetNumSpectators( void ); |
87 | 87 | ULONG HUD_GetRank( void ); |
88 | 88 | LONG HUD_GetSpread( void ); |
89 | -void HUD_SetRespawnTimeLeft( LONG lRespawnTime ); | |
89 | +void HUD_SetRespawnTimeLeft( float fRespawnTime ); | |
90 | 90 | FString HUD_SpellOrdinal( int ranknum, bool bColored = false ); |
91 | 91 | FString HUD_BuildPointString( void ); |
92 | 92 | FString HUD_BuildPlaceString( ULONG ulPlayer ); |
@@ -725,25 +725,24 @@ | ||
725 | 725 | if ((( zacompatflags & ZACOMPATF_INSTANTRESPAWN ) == false ) || |
726 | 726 | ( player->bSpawnTelefragged ) || ( bNoMoreLivesLeft )) |
727 | 727 | { |
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 )) | |
731 | 732 | { |
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; | |
737 | 735 | } |
738 | 736 | else |
739 | 737 | { |
740 | 738 | 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 ); | |
745 | 739 | } |
746 | 740 | |
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 | + | |
747 | 746 | // [BC] Don't respawn quite so fast on forced respawn. It sounds weird when your |
748 | 747 | // scream isn't completed. |
749 | 748 | // [RK] We can add on a custom force respawn delay instead drawn from the forcerespawn time CVAR |
@@ -2352,7 +2352,7 @@ | ||
2352 | 2352 | // [AK] Send sv_allowprivatechat. |
2353 | 2353 | command.addByte( sv_allowprivatechat ); |
2354 | 2354 | // [AK] Send sv_respawndelaytime. |
2355 | - command.addByte( sv_respawndelaytime ); | |
2355 | + command.addFloat( sv_respawndelaytime ); | |
2356 | 2356 | command.sendCommandToClients( ulPlayerExtra, flags ); |
2357 | 2357 | } |
2358 | 2358 |
@@ -457,23 +457,19 @@ | ||
457 | 457 | |
458 | 458 | //***************************************************************************** |
459 | 459 | // |
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; | |
470 | 466 | return; |
471 | 467 | } |
472 | 468 | |
473 | 469 | // [AK] Notify the clients about the change. |
474 | 470 | if (( NETWORK_GetState( ) == NETSTATE_SERVER ) && ( gamestate != GS_STARTUP )) |
475 | 471 | { |
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 )); | |
477 | 473 | SERVERCOMMANDS_SetGameModeLimits( ); |
478 | 474 | } |
479 | 475 | } |
@@ -694,7 +694,7 @@ | ||
694 | 694 | EXTERN_CVAR( Bool, sv_forcepassword ); |
695 | 695 | EXTERN_CVAR( Bool, sv_forcejoinpassword ); |
696 | 696 | EXTERN_CVAR( Int, sv_forcerespawntime ); // [RK] Delay used for forced respawn |
697 | -EXTERN_CVAR( Int, sv_respawndelaytime ); | |
697 | +EXTERN_CVAR( Float, sv_respawndelaytime ); | |
698 | 698 | EXTERN_CVAR( Bool, sv_showlauncherqueries ); |
699 | 699 | EXTERN_CVAR( Int, sv_maxclients ); |
700 | 700 | EXTERN_CVAR( Int, sv_maxplayers ); |