diff --git a/regamedll/dlls/buttons.cpp b/regamedll/dlls/buttons.cpp index 535aed66..833e239b 100644 --- a/regamedll/dlls/buttons.cpp +++ b/regamedll/dlls/buttons.cpp @@ -52,6 +52,16 @@ TYPEDESCRIPTION CEnvSpark::m_SaveData[] = #endif // HOOK_GAMEDLL + +#ifdef REGAMEDLL_FIXES + +TYPEDESCRIPTION CRotButton::m_SaveData[] = +{ + DEFINE_FIELD(CRotButton, m_vecSpawn, FIELD_VECTOR), +}; + +#endif + IMPLEMENT_SAVERESTORE(CEnvGlobal, CBaseEntity) LINK_ENTITY_TO_CLASS(env_global, CEnvGlobal, CCSEnvGlobal) @@ -875,6 +885,10 @@ void CRotButton::Spawn() pev->takedamage = DAMAGE_YES; } +#ifdef REGAMEDLL_FIXES + m_vecSpawn = pev->angles; +#endif + m_toggle_state = TS_AT_BOTTOM; m_vecAngle1 = pev->angles; m_vecAngle2 = pev->angles + pev->movedir * m_flMoveDistance; @@ -892,10 +906,16 @@ void CRotButton::Spawn() } else // touchable button SetTouch(&CRotButton::ButtonTouch); - - //SetTouch(ButtonTouch); } +#ifdef REGAMEDLL_FIXES +void CRotButton::Restart() +{ + pev->angles = m_vecSpawn; + Spawn(); +} +#endif + IMPLEMENT_SAVERESTORE(CMomentaryRotButton, CBaseToggle) LINK_ENTITY_TO_CLASS(momentary_rot_button, CMomentaryRotButton, CCSMomentaryRotButton) diff --git a/regamedll/dlls/buttons.h b/regamedll/dlls/buttons.h index c976d1de..0c51fae9 100644 --- a/regamedll/dlls/buttons.h +++ b/regamedll/dlls/buttons.h @@ -75,6 +75,15 @@ class CRotButton: public CBaseButton { public: virtual void Spawn(); + +#ifdef REGAMEDLL_FIXES + virtual void Restart(); + +public: + static TYPEDESCRIPTION m_SaveData[1]; + Vector m_vecSpawn; +#endif + }; class CMomentaryRotButton: public CBaseToggle diff --git a/regamedll/dlls/multiplay_gamerules.cpp b/regamedll/dlls/multiplay_gamerules.cpp index 0b584447..06ebcec9 100644 --- a/regamedll/dlls/multiplay_gamerules.cpp +++ b/regamedll/dlls/multiplay_gamerules.cpp @@ -691,6 +691,13 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CleanUpMap)() UTIL_RestartOther("light"); UTIL_RestartOther("func_breakable"); UTIL_RestartOther("func_door"); + +#ifdef REGAMEDLL_FIXES + UTIL_RestartOther("func_button"); + UTIL_RestartOther("func_rot_button"); + UTIL_RestartOther("trigger_push"); +#endif + UTIL_RestartOther("func_water"); UTIL_RestartOther("func_door_rotating"); UTIL_RestartOther("func_tracktrain"); @@ -701,25 +708,14 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(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("multisource"); + UTIL_RestartOther("trigger_auto"); #endif // Remove grenades and C4 -#ifdef REGAMEDLL_FIXES - UTIL_RemoveOther("grenade"); -#else - int icount = 0; - CBaseEntity *toremove = UTIL_FindEntityByClassname(NULL, "grenade"); - while (toremove && icount < 20) - { - UTIL_Remove(toremove); - toremove = UTIL_FindEntityByClassname(toremove, "grenade"); - ++icount; - } -#endif + const int grenadesRemoveCount = 20; + UTIL_RemoveOther("grenade", grenadesRemoveCount); // Remove defuse kit // Old code only removed 4 kits and stopped. diff --git a/regamedll/dlls/triggers.cpp b/regamedll/dlls/triggers.cpp index 9a8901e5..bdb15cf0 100644 --- a/regamedll/dlls/triggers.cpp +++ b/regamedll/dlls/triggers.cpp @@ -1594,23 +1594,9 @@ void CTriggerPush::Spawn() #ifdef REGAMEDLL_FIXES void CTriggerPush::Restart() { - InitTrigger(); - - if (pev->speed == 0) - { - pev->speed = 100; - } - - // if flagged to Start Turned Off, make trigger nonsolid. - if (pev->spawnflags & SF_TRIGGER_PUSH_START_OFF) - { - pev->solid = SOLID_NOT; - } - - SetUse(&CTriggerPush::ToggleUse); - - // Link into the list - UTIL_SetOrigin(pev, pev->origin); + auto tempDir = pev->movedir; + Spawn(); + pev->movedir = tempDir; } #endif diff --git a/regamedll/dlls/triggers.h b/regamedll/dlls/triggers.h index 6f081012..c5a98912 100644 --- a/regamedll/dlls/triggers.h +++ b/regamedll/dlls/triggers.h @@ -382,7 +382,6 @@ public: #ifdef REGAMEDLL_FIXES virtual void Restart(); - virtual int ObjectCaps() { return (CBaseEntity::ObjectCaps() | FCAP_MUST_RESET); } #endif }; diff --git a/regamedll/dlls/util.cpp b/regamedll/dlls/util.cpp index c1035ce3..ef0d0b9f 100644 --- a/regamedll/dlls/util.cpp +++ b/regamedll/dlls/util.cpp @@ -1498,11 +1498,17 @@ void UTIL_ResetEntities() } } -void UTIL_RemoveOther(const char *szClassname) +void UTIL_RemoveOther(const char *szClassname, int nRemoveCount) { + int num = 0; CBaseEntity *pEntity = nullptr; - while ((pEntity = UTIL_FindEntityByClassname(pEntity, szClassname)) != nullptr) + while ((pEntity = UTIL_FindEntityByClassname(pEntity, szClassname))) { +#ifndef REGAMEDLL_FIXES + if (nRemoveCount > 0 && num++ >= nRemoveCount) + break; +#endif + UTIL_Remove(pEntity); } } diff --git a/regamedll/dlls/util.h b/regamedll/dlls/util.h index 8f0286f8..2cfdeced 100644 --- a/regamedll/dlls/util.h +++ b/regamedll/dlls/util.h @@ -272,7 +272,7 @@ BOOL UTIL_IsValidEntity(edict_t *pent); void UTIL_PrecacheOther(const char *szClassname); void UTIL_RestartOther(const char *szClassname); void UTIL_ResetEntities(); -void UTIL_RemoveOther(const char *szClassname); +void UTIL_RemoveOther(const char *szClassname, int nCount = 0); void UTIL_LogPrintf(const char *fmt, ...); float UTIL_DotPoints(const Vector &vecSrc, const Vector &vecCheck, const Vector &vecDir); void UTIL_StripToken(const char *pKey, char *pDest); diff --git a/regamedll/extra/cssdk/dlls/buttons.h b/regamedll/extra/cssdk/dlls/buttons.h index 087417a7..91b573fe 100644 --- a/regamedll/extra/cssdk/dlls/buttons.h +++ b/regamedll/extra/cssdk/dlls/buttons.h @@ -65,6 +65,9 @@ public: class CRotButton: public CBaseButton { public: virtual void Spawn() = 0; + virtual void Restart() = 0; +public: + Vector m_vecSpawn; }; class CMomentaryRotButton: public CBaseToggle { diff --git a/regamedll/extra/cssdk/dlls/triggers.h b/regamedll/extra/cssdk/dlls/triggers.h index 576b4c3e..13d960a5 100644 --- a/regamedll/extra/cssdk/dlls/triggers.h +++ b/regamedll/extra/cssdk/dlls/triggers.h @@ -270,7 +270,6 @@ public: virtual void Spawn() = 0; virtual void Restart() = 0; virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int ObjectCaps() = 0; virtual void Touch(CBaseEntity *pOther) = 0; };