Added reset for multisource and trigger_auto (Related #55)

This commit is contained in:
s1lentq 2016-09-15 18:27:39 +07:00
parent 69b856a847
commit 7f45b10152
10 changed files with 45 additions and 13 deletions

View File

@ -170,6 +170,14 @@ void CMultiSource::__MAKE_VHOOK(Spawn)()
SetThink(&CMultiSource::Register);
}
#ifdef REGAMEDLL_FIXES
void CMultiSource::Restart()
{
Q_memset(m_rgTriggered, 0, sizeof(m_rgTriggered));
Spawn();
}
#endif
void CMultiSource::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)
{
int i = 0;

View File

@ -1078,14 +1078,13 @@ void OnFreeEntPrivateData(edict_t *pEnt)
pEntity->UpdateOnRemove();
RemoveEntityHashValue(pEntity->pev, STRING(pEntity->pev->classname), CLASSNAME);
#ifdef REGAMEDLL_ADD
#ifdef REGAMEDLL_API
if (pEntity->m_pEntity) {
delete pEntity->m_pEntity;
pEntity->m_pEntity = nullptr;
}
#endif
if (g_pMapInfo == pEntity)
g_pMapInfo = nullptr;
#endif
}

View File

@ -369,7 +369,7 @@ public:
void (CBaseEntity::*m_pfnUse)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
void (CBaseEntity::*m_pfnBlocked)(CBaseEntity *pOther);
#ifdef REGAMEDLL_ADD
#ifdef REGAMEDLL_API
CCSEntity *m_pEntity;
#else
// We use this variables to store each ammo count.
@ -435,6 +435,10 @@ public:
virtual BOOL IsTriggered(CBaseEntity *pActivator);
virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
#ifdef REGAMEDLL_FIXES
virtual void Restart();
#endif
#ifdef HOOK_GAMEDLL
void Spawn_();
@ -695,7 +699,7 @@ T *GetClassPtr(T *a)
a = new(pev) T;
a->pev = pev;
#ifdef REGAMEDLL_ADD
#ifdef REGAMEDLL_API
a->m_pEntity = new W();
a->m_pEntity->m_pContainingEntity = a;
#endif

View File

@ -679,7 +679,9 @@ void CHalfLifeMultiplay::__API_VHOOK(CleanUpMap)()
UTIL_RestartOther("env_sprite");
#ifdef REGAMEDLL_FIXES
UTIL_RestartOther("multisource");
UTIL_RestartOther("func_button");
UTIL_RestartOther("trigger_auto");
UTIL_RestartOther("trigger_once");
UTIL_RestartOther("multi_manager");
#endif

View File

@ -157,6 +157,16 @@ void CAutoTrigger::__MAKE_VHOOK(Think)()
}
}
#ifdef REGAMEDLL_FIXES
void CAutoTrigger::Restart()
{
if (pev->spawnflags & SF_AUTO_NO_RESET)
return;
pev->nextthink = gpGlobals->time + 0.1f;
}
#endif
LINK_ENTITY_TO_CLASS(trigger_relay, CTriggerRelay, CCSTriggerRelay);
IMPLEMENT_SAVERESTORE(CTriggerRelay, CBaseDelay);
@ -975,7 +985,7 @@ void CBaseTrigger::ActivateMultiTrigger(CBaseEntity *pActivator)
pev->nextthink = gpGlobals->time + 0.1f;
#ifdef REGAMEDLL_FIXES
if (!(pev->spawnflags & SF_TRIGGER_NO_RESTART) && m_flWait == -2)
if (!(pev->spawnflags & SF_TRIGGER_NO_RESET) && m_flWait == -2)
SetThink(NULL);
else
#endif
@ -1539,7 +1549,7 @@ void CTriggerPush::__MAKE_VHOOK(Touch)(CBaseEntity *pOther)
if (pevToucher->solid != SOLID_NOT && pevToucher->solid != SOLID_BSP)
{
// Instant trigger, just transfer velocity and remove
if (pev->spawnflags & SF_TRIG_PUSH_ONCE)
if (pev->spawnflags & SF_TRIGGER_PUSH_ONCE)
{
pevToucher->velocity = pevToucher->velocity + (pev->speed * pev->movedir);

View File

@ -42,8 +42,9 @@
#define SF_TRIGGER_ALLOWMONSTERS 1 // monsters allowed to fire this trigger
#define SF_TRIGGER_NOCLIENTS 2 // players not allowed to fire this trigger
#define SF_TRIGGER_PUSHABLES 4 // only pushables can fire this trigger
#define SF_TRIGGER_NO_RESTART 64 // it is not allowed to be restarted on a new round
#define SF_TRIGGER_NO_RESET 64 // it is not allowed to be resetting on a new round
#define SF_TRIGGER_PUSH_ONCE 1
#define SF_TRIGGER_PUSH_START_OFF 2 // spawnflag that makes trigger_push spawn turned OFF
#define SF_TRIGGER_HURT_TARGETONCE 1 // Only fire hurt target once
@ -53,6 +54,8 @@
#define SF_TRIGGER_HURT_CLIENTONLYTOUCH 32 // only clients may touch this trigger.
#define SF_AUTO_FIREONCE 0x0001
#define SF_AUTO_NO_RESET 0x0002
#define SF_RELAY_FIREONCE 0x0001
#define SF_ENDSECTION_USEONLY 0x0001
@ -108,6 +111,10 @@ public:
virtual int ObjectCaps() { return (CBaseDelay::ObjectCaps() & ~FCAP_ACROSS_TRANSITION); }
virtual void Think();
#ifdef REGAMEDLL_FIXES
virtual void Restart();
#endif
#ifdef HOOK_GAMEDLL
void Spawn_();

View File

@ -115,8 +115,6 @@ extern globalvars_t *gpGlobals;
#define SVC_ROOMTYPE 37
#define SVC_DIRECTOR 51
#define SF_TRIG_PUSH_ONCE 1
// func_rotating
#define SF_BRUSH_ROTATE_Y_AXIS 0
#define SF_BRUSH_ROTATE_INSTANT 1

View File

@ -269,6 +269,7 @@ class CBaseButton: public CBaseToggle {
public:
virtual void Spawn() = 0;
virtual void Precache() = 0;
virtual void Restart() = 0;
virtual void KeyValue(KeyValueData *pkvd) = 0;
virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0;
virtual int Save(CSave &save) = 0;
@ -299,6 +300,7 @@ public:
class CMultiSource: public CPointEntity {
public:
virtual void Spawn() = 0;
virtual void Restart() = 0;
virtual void KeyValue(KeyValueData *pkvd) = 0;
virtual int Save(CSave &save) = 0;
virtual int Restore(CRestore &restore) = 0;

View File

@ -37,8 +37,9 @@
#define SF_TRIGGER_ALLOWMONSTERS 1 // monsters allowed to fire this trigger
#define SF_TRIGGER_NOCLIENTS 2 // players not allowed to fire this trigger
#define SF_TRIGGER_PUSHABLES 4 // only pushables can fire this trigger
#define SF_TRIGGER_NO_RESTART 64 // it is not allowed to be restarted on a new round
#define SF_TRIGGER_NO_RESET 64 // it is not allowed to be restarted on a new round
#define SF_TRIGGER_PUSH_ONCE 1
#define SF_TRIGGER_PUSH_START_OFF 2 // spawnflag that makes trigger_push spawn turned OFF
#define SF_TRIGGER_HURT_TARGETONCE 1 // Only fire hurt target once
@ -48,6 +49,8 @@
#define SF_TRIGGER_HURT_CLIENTONLYTOUCH 32 // only clients may touch this trigger.
#define SF_AUTO_FIREONCE 0x0001
#define SF_AUTO_NO_RESET 0x0002
#define SF_RELAY_FIREONCE 0x0001
#define SF_ENDSECTION_USEONLY 0x0001
@ -82,6 +85,7 @@ class CAutoTrigger: public CBaseDelay {
public:
virtual void Spawn() = 0;
virtual void Precache() = 0;
virtual void Restart() = 0;
virtual void KeyValue(KeyValueData *pkvd) = 0;
virtual int Save(CSave &save) = 0;
virtual int Restore(CRestore &restore) = 0;

View File

@ -79,8 +79,6 @@ extern globalvars_t *gpGlobals;
#define SVC_ROOMTYPE 37
#define SVC_DIRECTOR 51
#define SF_TRIG_PUSH_ONCE 1
// func_rotating
#define SF_BRUSH_ROTATE_Y_AXIS 0
#define SF_BRUSH_ROTATE_INSTANT 1