From 7f45b101525c1f1454af09b2864d3cc2434031ee Mon Sep 17 00:00:00 2001 From: s1lentq Date: Thu, 15 Sep 2016 18:27:39 +0700 Subject: [PATCH] Added reset for multisource and trigger_auto (Related #55) --- regamedll/dlls/buttons.cpp | 8 ++++++++ regamedll/dlls/cbase.cpp | 5 ++--- regamedll/dlls/cbase.h | 8 ++++++-- regamedll/dlls/multiplay_gamerules.cpp | 2 ++ regamedll/dlls/triggers.cpp | 14 ++++++++++++-- regamedll/dlls/triggers.h | 9 ++++++++- regamedll/dlls/util.h | 2 -- regamedll/extra/cssdk/dlls/cbase.h | 2 ++ regamedll/extra/cssdk/dlls/triggers.h | 6 +++++- regamedll/extra/cssdk/dlls/util.h | 2 -- 10 files changed, 45 insertions(+), 13 deletions(-) diff --git a/regamedll/dlls/buttons.cpp b/regamedll/dlls/buttons.cpp index 0e377cc2..e246787a 100644 --- a/regamedll/dlls/buttons.cpp +++ b/regamedll/dlls/buttons.cpp @@ -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; diff --git a/regamedll/dlls/cbase.cpp b/regamedll/dlls/cbase.cpp index 1c8dd466..96a9d0bd 100644 --- a/regamedll/dlls/cbase.cpp +++ b/regamedll/dlls/cbase.cpp @@ -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 } diff --git a/regamedll/dlls/cbase.h b/regamedll/dlls/cbase.h index d251a474..7160bc9e 100644 --- a/regamedll/dlls/cbase.h +++ b/regamedll/dlls/cbase.h @@ -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 diff --git a/regamedll/dlls/multiplay_gamerules.cpp b/regamedll/dlls/multiplay_gamerules.cpp index 1b4f9f7a..626a76b8 100644 --- a/regamedll/dlls/multiplay_gamerules.cpp +++ b/regamedll/dlls/multiplay_gamerules.cpp @@ -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 diff --git a/regamedll/dlls/triggers.cpp b/regamedll/dlls/triggers.cpp index 0a365e5f..7d3b40b0 100644 --- a/regamedll/dlls/triggers.cpp +++ b/regamedll/dlls/triggers.cpp @@ -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); diff --git a/regamedll/dlls/triggers.h b/regamedll/dlls/triggers.h index 070e3c5f..9cb180ca 100644 --- a/regamedll/dlls/triggers.h +++ b/regamedll/dlls/triggers.h @@ -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_(); diff --git a/regamedll/dlls/util.h b/regamedll/dlls/util.h index 9a36aa34..9123fb13 100644 --- a/regamedll/dlls/util.h +++ b/regamedll/dlls/util.h @@ -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 diff --git a/regamedll/extra/cssdk/dlls/cbase.h b/regamedll/extra/cssdk/dlls/cbase.h index de414789..5118f509 100644 --- a/regamedll/extra/cssdk/dlls/cbase.h +++ b/regamedll/extra/cssdk/dlls/cbase.h @@ -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; diff --git a/regamedll/extra/cssdk/dlls/triggers.h b/regamedll/extra/cssdk/dlls/triggers.h index 57e9e08f..cdde9750 100644 --- a/regamedll/extra/cssdk/dlls/triggers.h +++ b/regamedll/extra/cssdk/dlls/triggers.h @@ -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; diff --git a/regamedll/extra/cssdk/dlls/util.h b/regamedll/extra/cssdk/dlls/util.h index e0d1d304..63174df0 100644 --- a/regamedll/extra/cssdk/dlls/util.h +++ b/regamedll/extra/cssdk/dlls/util.h @@ -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