From 22f5fe38319acd6b20b9b388caaa4e42a0019a95 Mon Sep 17 00:00:00 2001 From: s1lent Date: Wed, 18 Sep 2019 15:06:11 +0700 Subject: [PATCH] Grenade::Use: Move #C4_Defuse_Must_Be_On_Ground to beginning of defusing. --- regamedll/dlls/ggrenade.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/regamedll/dlls/ggrenade.cpp b/regamedll/dlls/ggrenade.cpp index 85bb14fb..e52d7ab5 100644 --- a/regamedll/dlls/ggrenade.cpp +++ b/regamedll/dlls/ggrenade.cpp @@ -1136,28 +1136,34 @@ void CGrenade::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTy // TODO: We must be sure that the activator is a player. CBasePlayer *pPlayer = GetClassPtr((CBasePlayer *)pActivator->pev); +#ifdef REGAMEDLL_FIXES + if (!pPlayer->IsPlayer()) + return; +#endif + // For CTs to defuse the c4 if (pPlayer->m_iTeam != CT) { return; } -#ifdef REGAMEDLL_FIXES - if ((pPlayer->pev->flags & FL_ONGROUND) != FL_ONGROUND) // Defuse should start only on ground - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#C4_Defuse_Must_Be_On_Ground"); - return; - } -#endif - if (m_bStartDefuse) { #ifdef REGAMEDLL_FIXES if (m_pBombDefuser == pPlayer) -#endif { + if ((pPlayer->pev->flags & FL_ONGROUND) != FL_ONGROUND) // Defuse should start only on ground + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#C4_Defuse_Must_Be_On_Ground"); + return; + } + m_fNextDefuse = gpGlobals->time + NEXT_DEFUSE_TIME; } +#else + m_fNextDefuse = gpGlobals->time + NEXT_DEFUSE_TIME; +#endif // #ifdef REGAMEDLL_FIXES + return; } @@ -1384,7 +1390,7 @@ void CGrenade::C4Think() // If the timer has expired ! blow this bomb up! #ifdef REGAMEDLL_FIXES - if(gpGlobals->time >= m_flC4Blow && (!(m_bStartDefuse && m_pBombDefuser) || gpGlobals->time < m_flDefuseCountDown)) // Prevent exploding after defusing. + if (gpGlobals->time >= m_flC4Blow && (!(m_bStartDefuse && m_pBombDefuser) || gpGlobals->time < m_flDefuseCountDown)) // Prevent exploding after defusing. #else if (gpGlobals->time >= m_flC4Blow) #endif