Skip to content

Commit

Permalink
various engine fixes from main repo pull requests
Browse files Browse the repository at this point in the history
-Fixed npc_manhack not notifying npc_template_maker/npc_maker when thrown and destroyed with gravity gun
ValveSoftware/source-sdk-2013#362

-Fixed server physics when server has custom tickrate
ValveSoftware/source-sdk-2013#515

-Fixed infinite recursion by using incorrect key on value conversation
ValveSoftware/source-sdk-2013#380

-Fix dereferencing null if m_iActiveSound is no longer valid index by save restore
ValveSoftware/source-sdk-2013#381

-Fix Linux soundscapes
ValveSoftware/source-sdk-2013#448

-Fix typo in logical expression
ValveSoftware/source-sdk-2013#502
  • Loading branch information
Baklojan committed Dec 21, 2024
1 parent de77bda commit b8d3161
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/game/client/physics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
10 changes: 8 additions & 2 deletions src/game/server/ai_basenpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3218,7 +3218,10 @@ void CAI_BaseNPC::UpdateEfficiency( bool bInPVS )
}
}

iSound = pCurrentSound->NextSound();
if ( pCurrentSound )
iSound = pCurrentSound->NextSound();
else
break;
}
}

Expand Down Expand Up @@ -3405,7 +3408,10 @@ void CAI_BaseNPC::UpdateSleepState( bool bInPVS )
break;
}

iSound = pCurrentSound->NextSound();
if ( pCurrentSound )
iSound = pCurrentSound->NextSound();
else
break;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/game/server/ai_behavior_assault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 4 additions & 1 deletion src/game/server/ai_senses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ void CAI_Senses::Listen( void )
m_iAudibleList = iSound;
}

iSound = pCurrentSound->NextSound();
if ( pCurrentSound )
iSound = pCurrentSound->NextSound();
else
break;
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/game/server/envmicrophone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,10 @@ void CEnvMicrophone::Think(void)
fHearSound = true;
}
}
nSound = pCurrentSound->NextSound();
}

nSound = pCurrentSound->NextSound();
else
break;
}

if( fHearSound )
Expand Down
10 changes: 8 additions & 2 deletions src/game/server/hl2/npc_manhack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
// -----------------------------------------------------------------
Expand Down Expand Up @@ -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 );
Expand All @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/game/server/hl2/npc_manhack.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ DECLARE_SERVERCLASS();
CSprite *m_pLightGlow;

CHandle<SmokeTrail> m_hSmokeTrail;
CHandle<CBaseEntity> m_pPrevOwner;

int m_iPanel1;
int m_iPanel2;
Expand Down
6 changes: 3 additions & 3 deletions src/game/server/physics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/game/server/soundscape_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() )
{
Expand Down
2 changes: 1 addition & 1 deletion src/game/shared/baseentity_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b8d3161

Please sign in to comment.