Skip to content

Commit bbafd6c

Browse files
authored
Merge pull request #269 from tmp64/feature/respawn-delay
Server: Add mp_respawn_delay cvar
2 parents e9e2274 + f0eb321 commit bbafd6c

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

src/game/server/game.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ cvar_t mp_notify_player_status = { "mp_notify_player_status", "7" }; // Notifica
6161

6262
ConVar mp_welcomecam("mp_welcomecam", "1", 0, "Don't spawn players immediately on join");
6363
ConVar mp_welcomecam_delay("mp_welcomecam_delay", "0.2", 0, "Delay before the player can leave welcome cam");
64-
cvar_t mp_respawn_fix = { "mp_respawn_fix", "1", FCVAR_SERVER };
64+
ConVar mp_respawn_fix("mp_respawn_fix", "1", 0, "Fix inconsistent respawn times and standing corpses");
65+
ConVar mp_respawn_delay("mp_respawn_delay", "1.5", 0, "Time until palyers can respawn after death. Requires mp_respawn_fix 1.");
6566

6667
cvar_t motdfile_unicode = { "motdfile_unicode", "motd_unicode.txt", FCVAR_SERVER };
6768
cvar_t motdfile_html = { "motdfile_html", "motd.html", FCVAR_SERVER };
@@ -523,8 +524,6 @@ void GameDLLInit(void)
523524
CVAR_REGISTER(&sv_busters);
524525
CVAR_REGISTER(&mp_notify_player_status);
525526

526-
CVAR_REGISTER(&mp_respawn_fix);
527-
528527
CVAR_REGISTER(&motdfile_unicode);
529528
CVAR_REGISTER(&motdfile_html);
530529

src/game/server/game.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ extern cvar_t allowmonsters;
4646
extern cvar_t mp_notify_player_status;
4747
extern ConVar mp_welcomecam;
4848
extern ConVar mp_welcomecam_delay;
49-
extern cvar_t mp_respawn_fix;
49+
extern ConVar mp_respawn_fix;
50+
extern ConVar mp_respawn_delay;
5051
extern ConVar mp_wallgauss;
5152
extern ConVar mp_rpg_fix;
5253
extern ConVar mp_blastradius;

src/game/server/player.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,18 +1406,24 @@ void CBasePlayer::PlayerDeathThink(void)
14061406
pev->angles.x = 0;
14071407

14081408
if (pev->modelindex && (!m_fSequenceFinished) && (pev->deadflag == DEAD_DYING))
1409-
StudioFrameAdvance();
1410-
1411-
if (mp_respawn_fix.value <= 0)
14121409
{
1410+
StudioFrameAdvance();
14131411
m_flRespawnTimer += gpGlobals->frametime;
1414-
if (m_flRespawnTimer < 4.0f) // 120 frames at 30fps -- animations should be no longer than this
1415-
return;
1412+
1413+
if (!mp_respawn_fix.GetBool())
1414+
{
1415+
// HL25 behavior: wait until animation ends.
1416+
// If animation is longer than 4 seconds, assume it finished.
1417+
if (m_flRespawnTimer < 4.0f)
1418+
return;
1419+
}
14161420
}
1417-
else
1421+
1422+
if (mp_respawn_fix.GetBool())
14181423
{
1424+
// BHL behavior: wait for fixed time
14191425
// time given to animate corpse and don't allow to respawn till this time ends
1420-
if (gpGlobals->time < m_flDeathAnimationStartTime + 1.5)
1426+
if (gpGlobals->time < m_flDeathAnimationStartTime + mp_respawn_delay.GetFloat())
14211427
return;
14221428
}
14231429

0 commit comments

Comments
 (0)