From 78e2bf215617d31fd4a13b9c66df55b984e3ae9d Mon Sep 17 00:00:00 2001 From: jhh8 Date: Mon, 20 Oct 2025 13:22:06 +0300 Subject: [PATCH 1/2] make doors not try to close when something is in the door area fixes #12 --- src/game/server/swarm/asw_door.cpp | 7 +++++++ src/game/server/swarm/asw_door.h | 3 +++ src/game/server/swarm/asw_door_area.cpp | 20 ++++++++++++++++++++ src/game/server/swarm/asw_door_area.h | 3 +++ src/game/server/triggers.cpp | 4 ++-- src/game/server/triggers.h | 2 +- 6 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/game/server/swarm/asw_door.cpp b/src/game/server/swarm/asw_door.cpp index 414de2ab4..a69eccd7b 100644 --- a/src/game/server/swarm/asw_door.cpp +++ b/src/game/server/swarm/asw_door.cpp @@ -605,6 +605,13 @@ bool CASW_Door::CheckDoorClear() return false; } + // dont try to close when an entity is standing inside any trigger_asw_door_area's that would make the door open + FOR_EACH_VEC( m_AttachedDoorAreas, i ) + { + if ( m_AttachedDoorAreas[i]->GetNumTouching() != 0 ) + return false; + } + if ( g_debug_doors.GetBool() ) { NDebugOverlay::Box( vecClosed, m_vecBoundsMin, m_vecBoundsMax, 0, 255, 0, true, 10.0f ); diff --git a/src/game/server/swarm/asw_door.h b/src/game/server/swarm/asw_door.h index ee220e904..7f7ddddd1 100644 --- a/src/game/server/swarm/asw_door.h +++ b/src/game/server/swarm/asw_door.h @@ -3,6 +3,7 @@ #include "entityblocker.h" #include "BasePropDoor.h" +#include "asw_door_area.h" #include "asw_shareddefs.h" class CASW_Player; @@ -152,6 +153,8 @@ class CASW_Door : public CBasePropDoor void UpdateDoorHealthOnMissionStart( int iDifficulty ); + CUtlVector m_AttachedDoorAreas; + private: float m_fLastFullyWeldedSound; diff --git a/src/game/server/swarm/asw_door_area.cpp b/src/game/server/swarm/asw_door_area.cpp index 1d165b5e2..1e3ecfefa 100644 --- a/src/game/server/swarm/asw_door_area.cpp +++ b/src/game/server/swarm/asw_door_area.cpp @@ -28,6 +28,26 @@ CASW_Door_Area::CASW_Door_Area() m_fNextCutCheck = 0; } +CASW_Door_Area::~CASW_Door_Area() +{ + CASW_Door *pDoor = GetDoor(); + if ( pDoor ) + { + pDoor->m_AttachedDoorAreas.FindAndRemove( this ); + } +} + +void CASW_Door_Area::Spawn( void ) +{ + BaseClass::Spawn(); + + CASW_Door *pDoor = GetDoor(); + if ( pDoor ) + { + pDoor->m_AttachedDoorAreas.AddToTail( this ); + } +} + bool CASW_Door_Area::HasWelder( CASW_Marine *pMarine ) { CASW_Weapon *pExtra = pMarine->GetASWWeapon( ASW_INVENTORY_SLOT_EXTRA ); diff --git a/src/game/server/swarm/asw_door_area.h b/src/game/server/swarm/asw_door_area.h index ce120dd79..cfd60e263 100644 --- a/src/game/server/swarm/asw_door_area.h +++ b/src/game/server/swarm/asw_door_area.h @@ -10,6 +10,9 @@ class CASW_Door_Area : public CASW_Use_Area DECLARE_CLASS( CASW_Door_Area, CASW_Use_Area ); public: CASW_Door_Area(); + ~CASW_Door_Area(); + + virtual void Spawn( void ); virtual void ActivateMultiTrigger( CBaseEntity *pActivator ); bool HasWelder( CASW_Marine *pMarine ); diff --git a/src/game/server/triggers.cpp b/src/game/server/triggers.cpp index 4e3c816bd..b89507edb 100644 --- a/src/game/server/triggers.cpp +++ b/src/game/server/triggers.cpp @@ -139,7 +139,7 @@ BEGIN_ENT_SCRIPTDESC( CBaseTrigger, CBaseEntity, "Server-side trigger" ) DEFINE_SCRIPTFUNC( Disable, "Disable the trigger" ) DEFINE_SCRIPTFUNC( Enable, "Enable the trigger" ) DEFINE_SCRIPTFUNC_NAMED( ScriptIsTouching, "IsTouching", "Checks whether the passed entity is touching the trigger." ) - DEFINE_SCRIPTFUNC_NAMED( ScriptGetNumTouching, "GetNumTouching", "Gets the number of entities currently touching the trigger." ) + DEFINE_SCRIPTFUNC( GetNumTouching, "GetNumTouching", "Gets the number of entities currently touching the trigger." ) DEFINE_SCRIPTFUNC_NAMED( ScriptGetTouching, "GetTouching", "Gets the i'th entity currently touching the trigger." ) END_SCRIPTDESC(); @@ -566,7 +566,7 @@ bool CBaseTrigger::ScriptIsTouching( HSCRIPT entity ) return IsTouching( pOther ); } -int CBaseTrigger::ScriptGetNumTouching() +int CBaseTrigger::GetNumTouching() { return m_hTouchingEntities.Count(); } diff --git a/src/game/server/triggers.h b/src/game/server/triggers.h index 89df0529e..8e25ebcff 100644 --- a/src/game/server/triggers.h +++ b/src/game/server/triggers.h @@ -58,7 +58,7 @@ class CBaseTrigger : public CBaseToggle bool IsTouching( CBaseEntity *pOther ); bool ScriptIsTouching( HSCRIPT entity ); - int ScriptGetNumTouching(); + int GetNumTouching(); HSCRIPT ScriptGetTouching( int i ); CBaseEntity *GetTouchedEntityOfType( const char *sClassName ); From fb8f237563d7e13e1e0444f78e64123f09a49cb0 Mon Sep 17 00:00:00 2001 From: jhh8 Date: Mon, 20 Oct 2025 13:27:36 +0300 Subject: [PATCH 2/2] fix getnumtouching description --- src/game/server/triggers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/server/triggers.cpp b/src/game/server/triggers.cpp index b89507edb..e4bbc37bb 100644 --- a/src/game/server/triggers.cpp +++ b/src/game/server/triggers.cpp @@ -139,7 +139,7 @@ BEGIN_ENT_SCRIPTDESC( CBaseTrigger, CBaseEntity, "Server-side trigger" ) DEFINE_SCRIPTFUNC( Disable, "Disable the trigger" ) DEFINE_SCRIPTFUNC( Enable, "Enable the trigger" ) DEFINE_SCRIPTFUNC_NAMED( ScriptIsTouching, "IsTouching", "Checks whether the passed entity is touching the trigger." ) - DEFINE_SCRIPTFUNC( GetNumTouching, "GetNumTouching", "Gets the number of entities currently touching the trigger." ) + DEFINE_SCRIPTFUNC( GetNumTouching, "Gets the number of entities currently touching the trigger." ) DEFINE_SCRIPTFUNC_NAMED( ScriptGetTouching, "GetTouching", "Gets the i'th entity currently touching the trigger." ) END_SCRIPTDESC();