Skip to content

Commit d7b6f77

Browse files
committed
Fix CItem::ActivateWhenAtRest() conflicting HL2MP FallThink
1 parent 975e630 commit d7b6f77

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/game/server/item_world.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,13 @@ void CItem::ActivateWhenAtRest( float flTime /* = 0.5f */ )
248248
{
249249
RemoveSolidFlags( FSOLID_TRIGGER );
250250
m_bActivateWhenAtRest = true;
251+
#if defined( HL2MP ) && defined( MAPBASE_MP )
252+
// HL2 entities (e.g. item_item_crate) often use ActivateWhenAtRest() before spawn, which is overridden by FallThink() in MP
253+
SetContextThink( &CItem::ComeToRest, gpGlobals->curtime + flTime, "ComeToRestThink" );
254+
#else
251255
SetThink( &CItem::ComeToRest );
252256
SetNextThink( gpGlobals->curtime + flTime );
257+
#endif
253258
}
254259

255260

@@ -266,8 +271,12 @@ void CItem::OnEntityEvent( EntityEvent_t event, void *pEventData )
266271
{
267272
// Delay rest for a sec, to avoid changing collision
268273
// properties inside a collision callback.
274+
#if defined( HL2MP ) && defined( MAPBASE_MP )
275+
SetContextThink( &CItem::ComeToRest, gpGlobals->curtime + 0.1f, "ComeToRestThink" );
276+
#else
269277
SetThink( &CItem::ComeToRest );
270278
SetNextThink( gpGlobals->curtime + 0.1f );
279+
#endif
271280
}
272281
break;
273282
}
@@ -283,7 +292,11 @@ void CItem::ComeToRest( void )
283292
{
284293
m_bActivateWhenAtRest = false;
285294
AddSolidFlags( FSOLID_TRIGGER );
295+
#if defined( HL2MP ) && defined( MAPBASE_MP )
296+
SetContextThink( NULL, TICK_NEVER_THINK, "ComeToRestThink" );
297+
#else
286298
SetThink( NULL );
299+
#endif
287300
}
288301
}
289302

0 commit comments

Comments
 (0)