Fix some things related #231

CGameText: add safe-checks to avoid crash on some maps
This commit is contained in:
s1lent 2017-12-31 18:24:51 +07:00
parent 565e9cd2b2
commit cff951afe7
No known key found for this signature in database
GPG Key ID: 0FE401DC73916B5C
4 changed files with 21 additions and 4 deletions

View File

@ -877,7 +877,9 @@ void CRotDoor::Restart()
// but spawn in the open position
if (pev->spawnflags & SF_DOOR_START_OPEN)
{
#ifndef REGAMEDLL_FIXES
#ifdef REGAMEDLL_FIXES
pev->angles = m_vecAngle1;
#else
pev->angles = m_vecAngle2;
Vector vecSav = m_vecAngle1;
@ -887,9 +889,11 @@ void CRotDoor::Restart()
pev->movedir = pev->movedir * -1;
}
#ifdef REGAMEDLL_FIXES
pev->angles = m_vecAngle1;
else if (pev->netname.IsNull())
{
pev->angles = m_vecAngle1;
}
#endif
m_toggle_state = TS_AT_BOTTOM;

View File

@ -181,6 +181,18 @@ void CGameText::KeyValue(KeyValueData *pkvd)
}
}
void CGameText::Spawn()
{
#ifdef REGAMEDLL_FIXES
// Don't allow entity triggering itself
if (FStrEq(pev->target, pev->targetname))
{
ALERT(at_warning, "%s \"%s\" the target applies to itself.\n", STRING(pev->classname), STRING(pev->targetname));
pev->target = iStringNull;
}
#endif
}
void CGameText::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)
{
if (!CanFireForActivator(pActivator))

View File

@ -96,6 +96,7 @@ public:
class CGameText: public CRulePointEntity
{
public:
virtual void Spawn();
virtual void KeyValue(KeyValueData *pkvd);
virtual int Save(CSave &save);
virtual int Restore(CRestore &restore);

View File

@ -136,7 +136,7 @@ void FireTargets(const char *targetName, CBaseEntity *pActivator, CBaseEntity *p
{
if (g_iTargetRecursionLevel++ > MAX_TARGET_RECURSION_LEVEL)
{
ALERT(at_warning, "Warning: %s \"%s\" triggered itself over %i times.\n", pCaller->pev->classname.str(), pCaller->pev->targetname.str(), MAX_TARGET_RECURSION_LEVEL);
ALERT(at_warning, "%s \"%s\" triggered itself over %i times.\n", pCaller->pev->classname.str(), pCaller->pev->targetname.str(), MAX_TARGET_RECURSION_LEVEL);
g_iTargetRecursionLevel = 0;
return;
}