From f46cb5a6354cd41d7569633819841d57d13e8f50 Mon Sep 17 00:00:00 2001 From: Saint146 Date: Thu, 4 May 2017 03:45:36 +0500 Subject: [PATCH] Added cvar mp_restart_round_delay (#109) * Added cvar bot_quota_mode * Added cvar mp_restart_round_delay --- regamedll/dlls/game.cpp | 2 ++ regamedll/dlls/game.h | 1 + regamedll/dlls/gamerules.h | 10 ++++++++ regamedll/dlls/multiplay_gamerules.cpp | 32 +++++++++++++------------- 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp index 8a3d316e..5e5177a2 100644 --- a/regamedll/dlls/game.cpp +++ b/regamedll/dlls/game.cpp @@ -109,6 +109,7 @@ cvar_t freeforall = { "mp_freeforall", "0", FCVAR_SERVER, 0.0f, nullptr }; cvar_t auto_join_team = { "mp_auto_join_team", "0", 0, 0.0f, nullptr }; cvar_t max_teamkills = { "mp_max_teamkills", "3", 0, 3.0f, nullptr }; cvar_t fraglimit = { "mp_fraglimit", "0", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t round_restart_delay = { "mp_round_restart_delay", "5", FCVAR_SERVER, 0.0f, nullptr }; cvar_t showtriggers = { "showtriggers", "0", 0, 0.0f, nullptr }; // debug cvar shows triggers // TODO: Maybe it's better to register in the engine? @@ -257,6 +258,7 @@ void EXT_FUNC GameDLLInit() CVAR_REGISTER(&auto_join_team); CVAR_REGISTER(&max_teamkills); CVAR_REGISTER(&fraglimit); + CVAR_REGISTER(&round_restart_delay); CVAR_REGISTER(&showtriggers); CVAR_REGISTER(&hostagehurtable); diff --git a/regamedll/dlls/game.h b/regamedll/dlls/game.h index 755d074f..4f8ec488 100644 --- a/regamedll/dlls/game.h +++ b/regamedll/dlls/game.h @@ -144,6 +144,7 @@ extern cvar_t freeforall; extern cvar_t auto_join_team; extern cvar_t max_teamkills; extern cvar_t fraglimit; +extern cvar_t round_restart_delay; extern cvar_t showtriggers; extern cvar_t hostagehurtable; diff --git a/regamedll/dlls/gamerules.h b/regamedll/dlls/gamerules.h index 50852e7d..72859030 100644 --- a/regamedll/dlls/gamerules.h +++ b/regamedll/dlls/gamerules.h @@ -764,6 +764,7 @@ public: void TerminateRound(float tmDelay, int iWinStatus); float GetRoundRespawnTime() const; + float GetRoundRestartDelay() const; // has a style of gameplay when aren't any teams bool IsFreeForAll() const; @@ -945,6 +946,15 @@ inline bool CHalfLifeMultiplay::IsFreeForAll() const return false; } +inline float CHalfLifeMultiplay::GetRoundRestartDelay() const +{ +#ifdef REGAMEDLL_ADD + return round_restart_delay.value; +#else + return ROUND_BEGIN_DELAY; +#endif +} + inline bool HasRoundInfinite(int flags = 0) { #ifdef REGAMEDLL_ADD diff --git a/regamedll/dlls/multiplay_gamerules.cpp b/regamedll/dlls/multiplay_gamerules.cpp index ec3688e1..99baef24 100644 --- a/regamedll/dlls/multiplay_gamerules.cpp +++ b/regamedll/dlls/multiplay_gamerules.cpp @@ -1186,12 +1186,12 @@ bool EXT_FUNC CHalfLifeMultiplay::VIPRoundEndCheck() { if (m_pVIP->m_bEscaped) { - return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::VIP_Escaped_internal, this, WINSTATUS_CTS, ROUND_VIP_ESCAPED, ROUND_BEGIN_DELAY); + return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::VIP_Escaped_internal, this, WINSTATUS_CTS, ROUND_VIP_ESCAPED, GetRoundRestartDelay()); } // The VIP is dead else if (m_pVIP->pev->deadflag != DEAD_NO) { - return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::VIP_Died_internal, this, WINSTATUS_TERRORISTS, ROUND_VIP_ASSASSINATED, ROUND_BEGIN_DELAY); + return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::VIP_Died_internal, this, WINSTATUS_TERRORISTS, ROUND_VIP_ASSASSINATED, GetRoundRestartDelay()); } } @@ -1278,15 +1278,15 @@ bool EXT_FUNC CHalfLifeMultiplay::PrisonRoundEndCheck(int NumAliveTerrorist, int if (m_flEscapeRatio >= m_flRequiredEscapeRatio) { - return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Prison_Escaped_internal, this, WINSTATUS_TERRORISTS, ROUND_TERRORISTS_ESCAPED, ROUND_BEGIN_DELAY); + return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Prison_Escaped_internal, this, WINSTATUS_TERRORISTS, ROUND_TERRORISTS_ESCAPED, GetRoundRestartDelay()); } else if (NumAliveTerrorist == 0 && m_flEscapeRatio < m_flRequiredEscapeRatio) { - return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Prison_PreventEscape_internal, this, WINSTATUS_CTS, ROUND_CTS_PREVENT_ESCAPE, ROUND_BEGIN_DELAY); + return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Prison_PreventEscape_internal, this, WINSTATUS_CTS, ROUND_CTS_PREVENT_ESCAPE, GetRoundRestartDelay()); } else if (NumAliveTerrorist == 0 && NumDeadTerrorist != 0 && m_iNumSpawnableCT > 0) { - return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Prison_Neutralized_internal, this, WINSTATUS_CTS, ROUND_ESCAPING_TERRORISTS_NEUTRALIZED, ROUND_BEGIN_DELAY); + return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Prison_Neutralized_internal, this, WINSTATUS_CTS, ROUND_ESCAPING_TERRORISTS_NEUTRALIZED, GetRoundRestartDelay()); } // else return true; } @@ -1346,11 +1346,11 @@ bool CHalfLifeMultiplay::BombRoundEndCheck() // Check to see if the bomb target was hit or the bomb defused.. if so, then let's end the round! if (m_bTargetBombed && m_bMapHasBombTarget) { - return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Target_Bombed_internal, this, WINSTATUS_TERRORISTS, ROUND_TARGET_BOMB, ROUND_BEGIN_DELAY); + return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Target_Bombed_internal, this, WINSTATUS_TERRORISTS, ROUND_TARGET_BOMB, GetRoundRestartDelay()); } else if (m_bBombDefused && m_bMapHasBombTarget) { - return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Target_Defused_internal, this, WINSTATUS_CTS, ROUND_BOMB_DEFUSED, ROUND_BEGIN_DELAY); + return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Target_Defused_internal, this, WINSTATUS_CTS, ROUND_BOMB_DEFUSED, GetRoundRestartDelay()); } return false; @@ -1432,19 +1432,19 @@ bool CHalfLifeMultiplay::TeamExterminationCheck(int NumAliveTerrorist, int NumAl if (!nowin) { - return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Round_Cts_internal, this, WINSTATUS_CTS, ROUND_CTS_WIN, ROUND_BEGIN_DELAY); + return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Round_Cts_internal, this, WINSTATUS_CTS, ROUND_CTS_WIN, GetRoundRestartDelay()); } } // Terrorists WON else if (NumAliveCT == 0 && NumDeadCT != 0) { - return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Round_Ts_internal, this, WINSTATUS_TERRORISTS, ROUND_TERRORISTS_WIN, ROUND_BEGIN_DELAY); + return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Round_Ts_internal, this, WINSTATUS_TERRORISTS, ROUND_TERRORISTS_WIN, GetRoundRestartDelay()); } } else if (NumAliveCT == 0 && NumAliveTerrorist == 0) { - return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Round_Draw_internal, this, WINSTATUS_DRAW, ROUND_END_DRAW, ROUND_BEGIN_DELAY); + return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Round_Draw_internal, this, WINSTATUS_DRAW, ROUND_END_DRAW, GetRoundRestartDelay()); } return false; @@ -1512,7 +1512,7 @@ bool CHalfLifeMultiplay::HostageRescueRoundEndCheck() { if (m_iHostagesRescued >= (iHostages * 0.5f)) { - return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Hostage_Rescue_internal, this, WINSTATUS_CTS, ROUND_ALL_HOSTAGES_RESCUED, ROUND_BEGIN_DELAY); + return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Hostage_Rescue_internal, this, WINSTATUS_CTS, ROUND_ALL_HOSTAGES_RESCUED, GetRoundRestartDelay()); } } @@ -3007,29 +3007,29 @@ void CHalfLifeMultiplay::CheckRoundTimeExpired() // New code to get rid of round draws!! if (m_bMapHasBombTarget) { - if (!g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Target_Saved_internal, this, WINSTATUS_CTS, ROUND_TARGET_SAVED, ROUND_BEGIN_DELAY)) + if (!g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Target_Saved_internal, this, WINSTATUS_CTS, ROUND_TARGET_SAVED, GetRoundRestartDelay())) return; } else if (UTIL_FindEntityByClassname(NULL, "hostage_entity")) { - if (!g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Hostage_NotRescued_internal, this, WINSTATUS_TERRORISTS, ROUND_HOSTAGE_NOT_RESCUED, ROUND_BEGIN_DELAY)) + if (!g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Hostage_NotRescued_internal, this, WINSTATUS_TERRORISTS, ROUND_HOSTAGE_NOT_RESCUED, GetRoundRestartDelay())) return; } else if (m_bMapHasEscapeZone) { - if (!g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Prison_NotEscaped_internal, this, WINSTATUS_CTS, ROUND_TERRORISTS_NOT_ESCAPED, ROUND_BEGIN_DELAY)) + if (!g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Prison_NotEscaped_internal, this, WINSTATUS_CTS, ROUND_TERRORISTS_NOT_ESCAPED, GetRoundRestartDelay())) return; } else if (m_bMapHasVIPSafetyZone) { - if (!g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::VIP_NotEscaped_internal, this, WINSTATUS_TERRORISTS, ROUND_VIP_NOT_ESCAPED, ROUND_BEGIN_DELAY)) + if (!g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::VIP_NotEscaped_internal, this, WINSTATUS_TERRORISTS, ROUND_VIP_NOT_ESCAPED, GetRoundRestartDelay())) return; } #ifdef REGAMEDLL_ADD else if (roundover.value) { // round is over - if (!g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::RoundOver_internal, this, WINSTATUS_DRAW, ROUND_GAME_OVER, ROUND_BEGIN_DELAY)) + if (!g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::RoundOver_internal, this, WINSTATUS_DRAW, ROUND_GAME_OVER, GetRoundRestartDelay())) return; } #endif