From b8d31616d8d8d9b9254ce89487f5281e5ecc044a Mon Sep 17 00:00:00 2001 From: Baklojan <77415005+Baklojan@users.noreply.github.com> Date: Sat, 21 Dec 2024 15:13:20 +0300 Subject: [PATCH] various engine fixes from main repo pull requests -Fixed npc_manhack not notifying npc_template_maker/npc_maker when thrown and destroyed with gravity gun https://github.com/ValveSoftware/source-sdk-2013/pull/362 -Fixed server physics when server has custom tickrate https://github.com/ValveSoftware/source-sdk-2013/pull/515 -Fixed infinite recursion by using incorrect key on value conversation https://github.com/ValveSoftware/source-sdk-2013/pull/380 -Fix dereferencing null if m_iActiveSound is no longer valid index by save restore https://github.com/ValveSoftware/source-sdk-2013/pull/381 -Fix Linux soundscapes https://github.com/ValveSoftware/source-sdk-2013/pull/448 -Fix typo in logical expression https://github.com/ValveSoftware/source-sdk-2013/pull/502 --- src/game/client/physics.cpp | 2 +- src/game/server/ai_basenpc.cpp | 10 ++++++++-- src/game/server/ai_behavior_assault.cpp | 2 +- src/game/server/ai_senses.cpp | 5 ++++- src/game/server/envmicrophone.cpp | 5 +++-- src/game/server/hl2/npc_manhack.cpp | 10 ++++++++-- src/game/server/hl2/npc_manhack.h | 1 + src/game/server/physics.cpp | 6 +++--- src/game/server/soundscape_system.cpp | 4 ++-- src/game/shared/baseentity_shared.cpp | 2 +- 10 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/game/client/physics.cpp b/src/game/client/physics.cpp index 5ed8ebe..d541588 100644 --- a/src/game/client/physics.cpp +++ b/src/game/client/physics.cpp @@ -168,7 +168,7 @@ void PhysicsLevelInit( void ) physenv->SetGravity( Vector(0, 0, -GetCurrentGravity() ) ); // 15 ms per tick // NOTE: Always run client physics at this rate - helps keep ragdolls stable - physenv->SetSimulationTimestep( DEFAULT_TICK_INTERVAL ); + physenv->SetSimulationTimestep( gpGlobals->interval_per_tick ); physenv->SetCollisionEventHandler( &g_Collisions ); physenv->SetCollisionSolver( &g_Collisions ); diff --git a/src/game/server/ai_basenpc.cpp b/src/game/server/ai_basenpc.cpp index 11f645a..6574092 100644 --- a/src/game/server/ai_basenpc.cpp +++ b/src/game/server/ai_basenpc.cpp @@ -3218,7 +3218,10 @@ void CAI_BaseNPC::UpdateEfficiency( bool bInPVS ) } } - iSound = pCurrentSound->NextSound(); + if ( pCurrentSound ) + iSound = pCurrentSound->NextSound(); + else + break; } } @@ -3405,7 +3408,10 @@ void CAI_BaseNPC::UpdateSleepState( bool bInPVS ) break; } - iSound = pCurrentSound->NextSound(); + if ( pCurrentSound ) + iSound = pCurrentSound->NextSound(); + else + break; } } } diff --git a/src/game/server/ai_behavior_assault.cpp b/src/game/server/ai_behavior_assault.cpp index e02627c..d57ec61 100644 --- a/src/game/server/ai_behavior_assault.cpp +++ b/src/game/server/ai_behavior_assault.cpp @@ -1257,7 +1257,7 @@ int CAI_AssaultBehavior::TranslateSchedule( int scheduleType ) break; case SCHED_HOLD_RALLY_POINT: - if( HasCondition(COND_NO_PRIMARY_AMMO) | HasCondition(COND_LOW_PRIMARY_AMMO) ) + if( HasCondition(COND_NO_PRIMARY_AMMO) || HasCondition(COND_LOW_PRIMARY_AMMO) ) { return SCHED_RELOAD; } diff --git a/src/game/server/ai_senses.cpp b/src/game/server/ai_senses.cpp index e16776d..e7d46ca 100644 --- a/src/game/server/ai_senses.cpp +++ b/src/game/server/ai_senses.cpp @@ -130,7 +130,10 @@ void CAI_Senses::Listen( void ) m_iAudibleList = iSound; } - iSound = pCurrentSound->NextSound(); + if ( pCurrentSound ) + iSound = pCurrentSound->NextSound(); + else + break; } } diff --git a/src/game/server/envmicrophone.cpp b/src/game/server/envmicrophone.cpp index 9e85b0d..67bd48b 100644 --- a/src/game/server/envmicrophone.cpp +++ b/src/game/server/envmicrophone.cpp @@ -403,9 +403,10 @@ void CEnvMicrophone::Think(void) fHearSound = true; } } + nSound = pCurrentSound->NextSound(); } - - nSound = pCurrentSound->NextSound(); + else + break; } if( fHearSound ) diff --git a/src/game/server/hl2/npc_manhack.cpp b/src/game/server/hl2/npc_manhack.cpp index feef84f..16ec44e 100644 --- a/src/game/server/hl2/npc_manhack.cpp +++ b/src/game/server/hl2/npc_manhack.cpp @@ -1144,7 +1144,7 @@ bool CNPC_Manhack::OverrideMove( float flInterval ) bool bReducible = GetNavigator()->GetPath()->GetCurWaypoint()->IsReducible(); const float strictTolerance = 64.0; //NDebugOverlay::Line( GetAbsOrigin(), GetAbsOrigin() + Vector(0, 0, 10 ), 255, 0, 0, true, 0.1); - if ( ProgressFlyPath( flInterval, GetEnemy(), MoveCollisionMask(), bReducible, strictTolerance ) == AINPP_COMPLETE ) + if ( ProgressFlyPath( flInterval, GetEnemy(), MoveCollisionMask(), bReducible, strictTolerance ) == AINPP_COMPLETE ) return true; } // ----------------------------------------------------------------- @@ -3007,6 +3007,9 @@ void CNPC_Manhack::OnPhysGunPickup( CBasePlayer *pPhysGunUser, PhysGunPickup_t r } else { + // FIX: Remember the current owner in case we are from a npc_template_maker/npc_maker. + m_pPrevOwner.Set( GetOwnerEntity() ); + // Suppress collisions between the manhack and the player; we're currently bumping // almost certainly because it's not purely a physics object. SetOwnerEntity( pPhysGunUser ); @@ -3023,7 +3026,10 @@ void CNPC_Manhack::OnPhysGunPickup( CBasePlayer *pPhysGunUser, PhysGunPickup_t r void CNPC_Manhack::OnPhysGunDrop( CBasePlayer *pPhysGunUser, PhysGunDrop_t Reason ) { // Stop suppressing collisions between the manhack and the player - SetOwnerEntity( NULL ); + SetOwnerEntity( m_pPrevOwner.Get() ); + + // Reset previous owner back to NULL. + m_pPrevOwner.Set( NULL ); m_bHeld = false; diff --git a/src/game/server/hl2/npc_manhack.h b/src/game/server/hl2/npc_manhack.h index 17a3ced..cdc7bd5 100644 --- a/src/game/server/hl2/npc_manhack.h +++ b/src/game/server/hl2/npc_manhack.h @@ -254,6 +254,7 @@ DECLARE_SERVERCLASS(); CSprite *m_pLightGlow; CHandle m_hSmokeTrail; + CHandle m_pPrevOwner; int m_iPanel1; int m_iPanel2; diff --git a/src/game/server/physics.cpp b/src/game/server/physics.cpp index 4aabf6c..be176e4 100644 --- a/src/game/server/physics.cpp +++ b/src/game/server/physics.cpp @@ -226,7 +226,7 @@ void CPhysicsHook::LevelInitPreEntity() physenv->SetObjectEventHandler( &g_Collisions ); - physenv->SetSimulationTimestep( DEFAULT_TICK_INTERVAL ); // 15 ms per tick + physenv->SetSimulationTimestep( gpGlobals->interval_per_tick ); // 15 ms per tick // HL Game gravity, not real-world gravity physenv->SetGravity( Vector( 0, 0, -GetCurrentGravity() ) ); g_PhysAverageSimTime = 0; @@ -1576,7 +1576,7 @@ CON_COMMAND( physics_budget, "Times the cost of each active object" ) float totalTime = 0.f; g_Collisions.BufferTouchEvents( true ); float full = engine->Time(); - physenv->Simulate( DEFAULT_TICK_INTERVAL ); + physenv->Simulate( gpGlobals->interval_per_tick ); full = engine->Time() - full; float lastTime = full; @@ -1593,7 +1593,7 @@ CON_COMMAND( physics_budget, "Times the cost of each active object" ) PhysForceEntityToSleep( ents[j], ents[j]->VPhysicsGetObject() ); } float start = engine->Time(); - physenv->Simulate( DEFAULT_TICK_INTERVAL ); + physenv->Simulate( gpGlobals->interval_per_tick ); float end = engine->Time(); float elapsed = end - start; diff --git a/src/game/server/soundscape_system.cpp b/src/game/server/soundscape_system.cpp index feccb28..23177a1 100644 --- a/src/game/server/soundscape_system.cpp +++ b/src/game/server/soundscape_system.cpp @@ -62,7 +62,7 @@ void CSoundscapeSystem::AddSoundscapeFile( const char *filename ) MEM_ALLOC_CREDIT(); // Open the soundscape data file, and abort if we can't KeyValues *pKeyValuesData = new KeyValues( filename ); - if ( filesystem->LoadKeyValues( *pKeyValuesData, IFileSystem::TYPE_SOUNDSCAPE, filename, "GAME" ) ) + if ( pKeyValuesData->LoadFromFile( filesystem, filename, "GAME" ) ) { // parse out all of the top level sections and save their names KeyValues *pKeys = pKeyValuesData; @@ -133,7 +133,7 @@ bool CSoundscapeSystem::Init() } KeyValues *manifest = new KeyValues( SOUNDSCAPE_MANIFEST_FILE ); - if ( filesystem->LoadKeyValues( *manifest, IFileSystem::TYPE_SOUNDSCAPE, SOUNDSCAPE_MANIFEST_FILE, "GAME" ) ) + if ( manifest->LoadFromFile( filesystem, SOUNDSCAPE_MANIFEST_FILE, "GAME" ) ) { for ( KeyValues *sub = manifest->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() ) { diff --git a/src/game/shared/baseentity_shared.cpp b/src/game/shared/baseentity_shared.cpp index 82f3310..241a78a 100644 --- a/src/game/shared/baseentity_shared.cpp +++ b/src/game/shared/baseentity_shared.cpp @@ -399,7 +399,7 @@ bool CBaseEntity::KeyValue( const char *szKeyName, const char *szValue ) } // Do this so inherited classes looking for 'angles' don't have to bother with 'angle' - return KeyValue( szKeyName, szBuf ); + return KeyValue( "angles", szBuf ); } // NOTE: Have to do these separate because they set two values instead of one