Fixes (attempt 999) (#413)

* Fix func_healthcharger & func_recharge bug
* active weapon check
* fix entity leak
* item_airbox: little optimizations
* Use IsPlayer check instead of FClassnameIs
This commit is contained in:
Vaqtincha 2019-09-17 17:06:21 +05:00 committed by Dmitry Novikov
parent 2632c98c98
commit b83d221ec4
5 changed files with 53 additions and 14 deletions

View File

@ -57,8 +57,12 @@ void CItemAirBox::Touch(CBaseEntity *pOther)
CArmoury::Touch(pOther);
// airbox was picked up, so sprite to turn off
if ((pev->effects & EF_NODRAW) == EF_NODRAW) {
if ((pev->effects & EF_NODRAW) == EF_NODRAW)
{
m_hSprite->TurnOff();
pev->nextthink = 0;
SetThink(nullptr);
}
}
@ -66,6 +70,12 @@ void CItemAirBox::Restart()
{
CArmoury::Restart();
UTIL_SetOrigin(pev, pev->oldorigin);
if (m_flyup > 0 && m_delay > 0.01f)
{
SetThink(&CItemAirBox::MoveUp);
pev->nextthink = gpGlobals->time + 0.1f;
}
}
void CItemAirBox::Precache()

View File

@ -817,7 +817,19 @@ void CBreakable::Die()
if (m_iszSpawnObject)
{
CBaseEntity::Create((char *)STRING(m_iszSpawnObject), VecBModelOrigin(pev), pev->angles, edict());
// TODO: Implement a list of entities to remove them on restart round
auto pItem = CBaseEntity::Create((char *)STRING(m_iszSpawnObject), VecBModelOrigin(pev), pev->angles, edict());
#ifdef REGAMEDLL_FIXES
// FIX: entity leak!
if (pItem)
{
pItem->pev->spawnflags |= SF_NORESPAWN;
pItem->SetThink(&CBaseEntity::SUB_Remove);
pItem->pev->nextthink = gpGlobals->time + CGameRules::GetItemKillDelay();
}
#endif
}
if (Explodable())

View File

@ -275,7 +275,12 @@ void CFuncTank::StopControl()
ALERT(at_console, "stopped using TANK\n");
m_pController->m_iHideHUD &= ~HIDEHUD_WEAPONS;
#ifdef REGAMEDLL_FIXES
if (m_pController->m_pActiveItem)
#endif
{
m_pController->m_iHideHUD &= ~HIDEHUD_WEAPONS;
}
pev->nextthink = 0;
m_pController = nullptr;

View File

@ -67,11 +67,6 @@ void CRecharge::Restart()
UTIL_SetSize(pev, pev->mins, pev->maxs);
SET_MODEL(ENT(pev), STRING(pev->model));
int armorValue = (int)gSkillData.suitchargerCapacity;
if (pev->armorvalue != 0.0f) {
armorValue = (int)pev->armorvalue;
}
pev->nextthink = pev->ltime + 0.1f;
SetThink(&CRecharge::Recharge);
}
@ -86,12 +81,25 @@ void CRecharge::Precache()
void CRecharge::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)
{
// if it's not a player, ignore
if (!FClassnameIs(pActivator->pev, "player"))
#ifdef REGAMEDLL_FIXES
// Make sure that we have a caller
if (!pActivator)
return;
// if it's not a player, ignore
if (!pActivator->IsPlayer())
return;
#else
if (!FClassnameIs(pActivator->pev, "player"))
return;
#endif // #ifdef REGAMEDLL_FIXES
// if there is no juice left, turn it off
if (m_iJuice <= 0)
if (m_iJuice <= 0
#ifdef REGAMEDLL_FIXES
&& pev->frame != 1.0f // recharging... don't reset think
#endif
)
{
pev->frame = 1.0f;
Off();
@ -126,7 +134,7 @@ void CRecharge::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useT
m_hActivator = pActivator;//EHANDLE::CBaseEntity *operator=
//only recharge the player
// only recharge the player
if (!m_hActivator->IsPlayer())
return;

View File

@ -138,7 +138,11 @@ void CWallHealth::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE us
return;
// if there is no juice left, turn it off
if (m_iJuice <= 0)
if (m_iJuice <= 0
#ifdef REGAMEDLL_FIXES
&& pev->frame != 1.0f // recharging... don't reset think
#endif
)
{
pev->frame = 1.0f;
Off();