# HG changeset patch # User Adam Kaminski # Date 1637523680 18000 # Sun Nov 21 14:41:20 2021 -0500 # Node ID a891e998c7b4d0e8ef97f445206929f03790384f # Parent 0fa647e1dc712d32843ddf870e01e2f651695247 Show how long a player must wait before respawning on the bottom of the screen if sv_respawndelaytime is greater than 1. diff -r 0fa647e1dc71 -r a891e998c7b4 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 @@ ClientObituary( players[ulPlayer].mo, pInflictor, NULL, MOD ); */ + // [AK] If we died, show how long we must wait before we can respawn if it's more than one second. + if ( player - players == consoleplayer ) + { + bool bNoMoreLivesLeft = ( GAMEMODE_AreLivesLimited( ) && GAMEMODE_IsGameInProgress( ) && ( player->ulLivesLeft == 0 )); + + if (( sv_respawndelaytime > 1 ) && ( player->mo->DamageType != NAME_SpawnTelefrag ) && ( bNoMoreLivesLeft == false )) + HUD_SetRespawnTimeLeft( sv_respawndelaytime ); + else + HUD_SetRespawnTimeLeft( -1 ); + } + // Refresh the HUD, since this could affect the number of players left in an LMS game. HUD_Refresh( ); } @@ -5902,6 +5913,10 @@ // [AK] Read in, and set the value for sv_allowprivatechat. Value.Int = pByteStream->ReadByte(); sv_allowprivatechat.ForceSet( Value, CVAR_Int ); + + // [AK] Read in, and set the value for sv_respawndelaytime. + Value.Int = pByteStream->ReadByte(); + sv_respawndelaytime.ForceSet( Value, CVAR_Int ); } //***************************************************************************** diff -r 0fa647e1dc71 -r a891e998c7b4 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 @@ // [AK] Who are the two duelers? static player_t *g_pDuelers[2]; +// [AK] How long we have to wait until we can respawn (-1 means disabled). +static LONG g_lRespawnDelay = -1; + +// [AK] At what tic will we be able to respawn? +static LONG g_lRespawnGametic = 0; + //***************************************************************************** // PROTOTYPES @@ -529,6 +535,18 @@ } } + // [AK] Show how much time is left before we can respawn if we had to wait for more than one second. + if (( players[consoleplayer].bSpectating == false ) && ( players[consoleplayer].playerstate == PST_DEAD )) + { + if ( g_lRespawnGametic > level.time ) + { + ULONG ulTimeLeft = MIN( g_lRespawnDelay, 1 + ( g_lRespawnGametic - level.time ) / TICRATE ); + + bottomString += "\n" TEXTCOLOR_GREEN; + bottomString.AppendFormat( "Ready to respawn in %d second%s", ulTimeLeft, ulTimeLeft != 1 ? "s" : "" ); + } + } + // If the console player is spectating, draw the spectator message. // [BB] Only when not in free spectate mode. if (( r_drawspectatingstring ) && ( players[consoleplayer].bSpectating ) && ( CLIENTDEMO_IsInFreeSpectateMode( ) == false )) @@ -953,6 +971,18 @@ //***************************************************************************** // +void HUD_SetRespawnTimeLeft( LONG lRespawnTime ) +{ + // [AK] The server shouldn't execute this. + if ( NETWORK_GetState( ) == NETSTATE_SERVER ) + return; + + g_lRespawnDelay = lRespawnTime; + g_lRespawnGametic = level.time + g_lRespawnDelay * TICRATE; +} + +//***************************************************************************** +// // [TP] Now in a function // FString HUD_SpellOrdinal( int ranknum, bool bColored ) diff -r 0fa647e1dc71 -r a891e998c7b4 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 @@ ULONG HUD_GetNumSpectators( void ); ULONG HUD_GetRank( void ); LONG HUD_GetSpread( void ); +void HUD_SetRespawnTimeLeft( LONG lRespawnTime ); FString HUD_SpellOrdinal( int ranknum, bool bColored = false ); FString HUD_BuildPointString( void ); FString HUD_BuildPlaceString( ULONG ulPlayer ); diff -r 0fa647e1dc71 -r a891e998c7b4 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 @@ // [AK] The respawn delay can be adjusted, but the minimum is one second. This only works if // the player wasn't spawn telefragged and still has lives left. if (( sv_respawndelaytime > 1 ) && ( player->bSpawnTelefragged == false ) && ( bNoMoreLivesLeft == false )) + { player->respawn_time = level.time + sv_respawndelaytime * TICRATE; + + // [AK] Show how long we must wait until we can respawn on the screen. + if ( player - players == consoleplayer ) + HUD_SetRespawnTimeLeft( sv_respawndelaytime ); + } else + { player->respawn_time = level.time + TICRATE; + + // [AK] We don't need to show how long to wait before we can respawn here. + if ( player - players == consoleplayer ) + HUD_SetRespawnTimeLeft( -1 ); + } // [BC] Don't respawn quite so fast on forced respawn. It sounds weird when your // scream isn't completed. diff -r 0fa647e1dc71 -r a891e998c7b4 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 @@ command.addByte( sv_limitcommands ); // [AK] Send sv_allowprivatechat. command.addByte( sv_allowprivatechat ); + // [AK] Send sv_respawndelaytime. + command.addByte( sv_respawndelaytime ); command.sendCommandToClients( ulPlayerExtra, flags ); } diff -r 0fa647e1dc71 -r a891e998c7b4 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 @@ CVAR( Bool, sv_forcepassword, false, CVAR_ARCHIVE|CVAR_NOSETBYACS|CVAR_SERVERINFO ) CVAR( Bool, sv_forcejoinpassword, false, CVAR_ARCHIVE|CVAR_NOSETBYACS|CVAR_SERVERINFO ) CVAR( Int, sv_forcerespawntime, 0, CVAR_ARCHIVE|CVAR_SERVERINFO ) // [RK] -CVAR( Int, sv_respawndelaytime, 1, CVAR_ARCHIVE|CVAR_SERVERINFO ) // [AK] CVAR( Bool, sv_showlauncherqueries, false, CVAR_ARCHIVE ) CVAR( Bool, sv_timestamp, false, CVAR_ARCHIVE|CVAR_NOSETBYACS ) CVAR( Int, sv_timestampformat, 0, CVAR_ARCHIVE|CVAR_NOSETBYACS ) @@ -456,6 +455,29 @@ } //***************************************************************************** +// +CUSTOM_CVAR( Int, sv_respawndelaytime, 1, CVAR_ARCHIVE | CVAR_SERVERINFO ) +{ + if ( self < 1 ) + { + self = 1; + return; + } + else if ( self > 255 ) + { + self = 255; + return; + } + + // [AK] Notify the clients about the change. + if (( NETWORK_GetState( ) == NETSTATE_SERVER ) && ( gamestate != GS_STARTUP )) + { + SERVER_Printf( "%s changed to: %d\n", self.GetName( ), self.GetGenericRep( CVAR_Int ).Int ); + SERVERCOMMANDS_SetGameModeLimits( ); + } +} + +//***************************************************************************** // FUNCTIONS void SERVER_Construct( void )